When making an SSH connection on Linux, after a few minutes of inactivity, the connection is lost. In this tutorial, we’ll teach you how to keep an SSH connection alive on Linux.
We will edit the “/etc/ssh/ssh_config” file :
nano /etc/ssh/ssh_config
Then simply “uncomment” or add the following lines:
Host *
ServerAliveInterval 30
ServerAliveCountMax 2
Restart the SSH Client:
service ssh restart