Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having problem that my network router reboots occasionally and because of that my ssh connection via terminal to my Ubuntu server is ended. The internet connection is just temporary disrupted and don't want to processes I'm running in the terminal are killed.

On my client ~/.ssh/config I have:

TCPKeepAlive yes
ServerAliveCountMax 10
ServerAliveInterval 5

But tuning of the above parameters does not help. The server sshd has default ubuntu parameters.

How to setup ssh on client (Mac OS in my case) and sshd on server (Ubuntu in my case) so that my ssh sessions survive reboot of router?

Thanks!

share|improve this question
    
possible duplicate of SSH tunnel in Ubuntu –  dtmland Jul 26 '13 at 22:42
    
Related: How can I logout an open, remote SSH session? –  Breakthrough Jul 31 '13 at 17:42

4 Answers 4

up vote 2 down vote accepted

Due to the nature of the underlying protocol ssh uses (TCP), the connections will drop after a certain amount of timeout. I tend to get around these issues in one of two ways:

1) use screen on the remote server and re-attach after the connection is restored. 2) setup up a VPN (such as openvpn) and use udp transmission, which allows for network interruptions (as well as, with a bit of configuration, source IP changes).

share|improve this answer

You can accomplish this with autossh

a simple program that allows you to run an instance of ssh - keeps it under control, and restarting the same instance once that the connection is dropped up to a maximum number of times controlled by the environment variable AUTOSSH_MAXSTART or indefinitely if the value of this is negative (the default).

Combining this solution with screen (first mentioned by Drav) is even better.

share|improve this answer

Since your server and client are both well supported, I highly recommend MOSH. MOSH uses SSH, but is designed for mobility, so that you can connect, disconnect, change IP, etc., and it will try to do the right thing and keep you connected. Even if you get disconnected, it will auto-connect, and put you right back where you were.

The main down-side to MOSH is that it does require installing extra software and it is not supported on every platform. Windows has semi-native support via MobaXTerm, and it doesn't work on things like VMWare ESXi, which have only vanilla SSH support.

MOSH also helps on slow links by enabling "predictive input", where what you type basically echos locally while the system figures out whether or not it really should.

share|improve this answer

Your above mentioned parameter must be set on the ssh server site as well. Only on client side did not help. If you do not have the rights to fit the sshd configuration. I might use ssh clients which support an inherent ssh keep live. The send some data to keep the connection up. Putty can do that for windows, SecureCRT can do that mac. Perhaps there are additional clients out there, which support this feature.

share|improve this answer

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.