Login to your remote system, or open the terminal in your own computer. Open the /etc/ssh/ssh_config file. and add the following line to the end of the file: What this option does is to send a null packet to the server at every 60 seconds (of inactivity) to keep the SSH connection alive. You can experiment with the value, setting it to either higher or lower, depending on your system configuration. A value of 60 is a good starting point to start the experimentation.

Per user configuration

If you don’t have root access to the system or you just want to configure it for your personal account, you can edit the ~/.ssh/config file instead. If the file does not exist, this will create a new file. Add the following line: Press “Ctrl + o” to save and “Ctrl + x” to exit. Lastly, restart the SSH server. That’s it.