Maybe it’s just me, but I constantly get annoyed with my ssh sessions disconnecting due to inactivity. It’s common for me to keep multiple sessions open throughout the day while I’m working. I like to monitor machines or just have those sessions handy. Well, there are a two solutions that work. (One client side, and one Server side). I’ll discuss both of them. (As if there was anything to discuss.. You just want it fixed!)
Solution 1: (Server Side Prevention)
If you add the following line to your /etc/sshd_config file, your connections will never disconnect regardless of the client you’re using. It’s great if it’s your server or a server you have root access to.
After that’s been added, just restart the sshd daemon with:
service sshd restart
Solution 2: (Client Side)
On the client side, just modify your ~/.ssh/config file and add the following line:
Host * ServerAliveInterval 60
That’s literally it!