If the SSH server you are connecting to has a timeout set in its configuration, it normally disconnects you after some time of inactivity to free up its resources. Adding a simple line of code to your ssh_config or ssh alias can help you stay connected “forever”.
Additionally this post assumes you do not have admin privilages to the ssh server.
Here is the code:
ssh -o ServerAliveInterval=30 -YC4c arcfour,blowfish-cbc user@ssh-server.com
Here the flag ‘-o’ sets the option name to send Alive packages to the server every 30 seconds. The ‘-c’ flag sets some encryption protocol. Read your server side ‘cpuinfo’ to see available protocols:
more /proc/cpuinfo | grep flags
Back to the main topic: The ‘-o’ flag can be added as default in your ssh-config by editing ~/.ssh/config to add the line :
ServerAliveInterval 30
Hope this helps someone.