Thursday, January 07, 2016

Keep Your SSH Session ALIVE!!

Most of us have had those days where we have a bunch of windows open, ssh'd into multiple servers.  You get caught up working on one of those servers and forget about your other ssh sessions.  Or, if you are like me, you are using something like screen/tmux and have many sessions going at the same time that you want to keep alive.

Well, with the default ssh setup, there is a setting in your ssh_config file called "ServerAliveInterval".  Initially (at least on my system) it is commented out and also has a value of zero (0).  

In order to keep your sessions alive indefinitely, you will need to uncomment that variable in the ssh_config file and set it to a value other than zero.  I have mine set to 60. 

What this variable does is tell ssh that it needs to send a packet across the wire to the connected server so that there is traffic, keeping the connection active, not letting it time out. 


So, by to keep your sessions alive, you will need to make the changes as above, but also, do not forget that this change will only effect new connections made after you save the change.  If you have active connections, you will need to exit them out and restart them.  If you don't, they will still be subject to the same issue you just corrected.

Go now, keep those connections alive! 

No comments:

 
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.