If you are anything like me, you often access a server or two through ssh. Personally, I have my network server that runs Ubuntu 11.10 server, as a media (and more) server. Being that I have limited physical access, since its shoved into a closet, and there is no graphical desktop installed on it, I only ever access it via SSH. The problem is, many times, I open a connection, then get busy doing something else, go back to my terminal to find the ENTIRE terminal is frozen due to my SSH connection timing out. so I have to close my terminal, and the login session hangs on my server, leaving ANY process I was running hosed. This really becomes a problem when running tools on the server, like Metasploit, or editing config files.
I finally got fed up enough to start digging through my SSH configs and try to find the solution. after reading the config files and comments, finding no settings about time out, I used the hackers best friend (Google) and found that it’s not actually a server-side setting I needed to change at all, It’s actually Client-side.
If you would like to prevent your connection from timing out, you can add the following line to your config file (/etc/ssh/ssh_config):
This will send a keep alive packet to the server every “xx” seconds. Keep in mind that if you do not close your SSH connection, it will be possible for others to hijack the session. this is strictly a convenience setting, and should be used with extreme caution.