Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

A lot of work gets done using SSH and one of the most frustrating things to happen is when the remote server disconnects you due to inactivity, but while you had your environment set up just the right way for the tasks you were doing. Imagine that you had to have a number of environment variables set just right in your remote shell and you stepped out for lunch only to come back to this...
puttysshtimeout2.png

 Terminal
[[email protected] ~]$ Connection to myserver closed by remote host.
Connection to myserver closed.


Frustration! You have to start all over again! Well there is a way to actually prevent this from happening in the first place by using the SSH server keep-alive setting.

If you're using PuTTY, in the connection preferences you can set a value to send a 'heartbeat' to the server, 60 is a good value to use.
puttysshtimeout1.png




If you're connecting from a Unix based environment simply edit your ~/.ssh/config file (or create one if it doesn't exist) and set it up like this...
 .ssh/config
Host *
ServerAliveInterval 60


Instead of * you can specify an actual server hostname but it makes sense to have it configured for all servers with a wildcard.

-i

Skip down to comments...
Hope you found this post useful...

...so please read on! I love writing articles that provide beneficial information, tips and examples to my readers. All information on my blog is provided free of charge and I encourage you to share it as you wish. There is a small favour I ask in return however - engage in comments below, provide feedback, and if you see mistakes let me know.

If you want to show additional support and help me pay for web hosting and domain name registration, donations, no matter how small, are always welcome!

Use of any information contained in this blog post/article is subject to this disclaimer.
 
comments powered by Disqus
Other posts you may like...