I’m the jot down of geek that has an SSH client open at all times, connected to my most frequently used servers so that I have instant access for monitoring and anything else.
As such, it irritates me greatly when I get disconnected, so I’m sharing a few methods for keeping your session alive.
it’s possible for you to configure the ssh client to automatically send a protocol no-op code code every number of seconds so that the server won’t disconnect you.
This is setting is sometimes referred to as Keep-Alive or Stop-Disconnecting-So-Much in other clients.Global ConfigurationAdd the following line to the /etc/ssh/ssh_config file:
ServerAliveInterval 60
The number is the amount of seconds before the server with send the no-op code.Current User ConfigurationAdd the following lines to the ~/.ssh/config file (create if it doesn’t exist)
Host *ServerAliveInterval 60
double-check you indent the second line with a space.Per-Host ConfigurationIf you only want to enable keep alive for a single server, it’s possible for you to add that into the ~/.ssh/config file with the following syntax:
Host *hostname.comServerAliveInterval 60
Works quite well, hope it helps somebody else out there.