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
add comment

2 Answers

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
add comment

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
add comment

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.