Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am installed Ubuntu on Virtual Box, and use xshell (a remote terminal application) to ssh to ubuntu. when I hibernate computer during night, after powering it on, the session is expired and I should to ssh to ubuntu again. Is there is way to configure ssh to nut expire during hibernation or after hours of ideal connection? I use Fedora to, if configs have differences please mention it. I use Windows 7.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Try tmux. On the server side:

sudo apt-get install tmux

After logging in, start tmux.

tmux

If the connection breaks, log in again via ssh and reconnect the tmux session. To discover the session number:

tmux ls

The output might be something like this:

0: 1 windows (created Wed Jan 9 12:27:40 2013)

Connect to the tmux numbered session like this:

tmux attach -t 0

Then you are right back where you left it.

share|improve this answer
    
Or GNU screen. Either don't leave ssh connected and instead use some detachable middleware, or use something other than plain ssh. –  njsg Jan 9 '13 at 16:31
3  
Yup! GNU screen works, too. I would use either but enjoy tmux. Here is interesting article asking the question, "Is tmux the GNU screen killer?" techrepublic.com/blog/opensource/is-tmux-the-gnu-screen-killer/… –  Christopher Jan 9 '13 at 18:38

No. ssh is a TCP-based protocol with no support for "hibernation" or even for "roaming" (IP address changes). You will need something else if terminating the ssh connection before hibernating and connecting again when you resume is not desirable.

Perhaps give mosh ("the mobile shell") a try.

But, for short, no. TCP connections are closed on timeout, and ssh does not include any strategy to deal with that.

share|improve this answer
    
But ssh has parameters ConnectionTimeout and remote terminal apps has keepalive message interval parameters. Cannot these parameters be used for this purpose? –  XinHua Jan 9 '13 at 16:39
2  
No. That could work to a certain extent, if you are connecting from the same address after resuming, but it always has a time, and you need to have access to both client and server to change the timeout (it's of no use to have a large timeout on your side if the server still has the default value). keepalive is to send "keepalive" messages to avoid cases where the connection is dropped due to inactivity. A basic requirement of this is that you must be on and connected to send the keepalive messages... those won't help you at all with hibernation. –  njsg Jan 9 '13 at 17:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.