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

It's a familiar sight, you have an SSH session open and have to step away from your computer for a few minutes. When you come back, your SSH session has been disconnected with an error like this...
Connection to myserver closed by remote host.
Connection to myserver closed.

Not cool SSH, not cool!

The error is due to an inactivity time out and is easily addressed. All you have to do is tell your SSH client to send a keep-alive packet every so often so that the SSH server will not disconnect you. To do that, edit your ~/.ssh/config file and make sure the following two lines are present:
KeepAlive yes
ServerAliveInterval 30

That's all there is to it. After making those changes the next time you connect via SSH you will not be disconnected due to inactivity.


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...