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...
 Terminal
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:
 ~/.ssh/config
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.

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.