

$ sudo nano /etc/ssh/sshd_configĪdd the following rules to the configuration file, then save and close. Under Sending of null packets to keep session active, in the Seconds between keepalives, type 240. To achieve this, open and edit your /etc/ssh/sshd_config or /etc/ssh/ssh_config configuration file depending upon the distribution type. If you are operating the SSH daemon from the remote machine, then you might prefer to extend the session timeout from the remote machine for the client connection.Īlso Read: How can I Identify who SSH into my Linux System? Keep SSH Terminal Session Alive from Server Machine That’s all you need to do to keep the SSH terminal session alive from your local machine. If you want to specify the rules for the specific host, then modify the host value as shown below.

Keep SSH Terminal Session Alive from Client Machine To resolve this issue, you can make configuration changes either on the client machine located at ~/.ssh/config or on the server machine located at /etc/ssh/sshd_config or /etc/ssh/ssh_config.
#ITERM2 KEEP SSH SESSION ALIVE HOW TO#
However, this is a default nature of the SSH to prevent unauthorized access in case the client left the session open for a long period of time.Īlso Read: Do You Know How To Secure The OpenSSH Server? When you establish an SSH connection between the client and remote machine, they are active until the connection becomes idle. A buried session is a session that continues to run but is not a part of any window. How Do I Keep an SSH Terminal Session Alive in Linux?īefore you understand different ways to prevent SSH terminal sessions from disconnecting, you need to understand the workings behind this mechanism and how they get disconnected after a certain time. To make your OpenSSH server keep all connections alive with clients, add the following to /etc/ssh/sshdconfig: ClientAliveInterval 300 ClientAliveCountMax 2. OpenSSH Server: Ensure you have this tool on your remote system to receive the client connection.OpenSSH Client: Ensure you have this tool on your client system to establish the remote connection.Bonus Tip! Quickly Prevent the Server from Closing the Session.Keep SSH Terminal Session Alive from Server Machine.You can add it in the /etc/ssh/sshconfig file like so.

Keep SSH Terminal Session Alive from Client Machine You’ve finished the first part with the questions you’ve provided.How Do I Keep an SSH Terminal Session Alive in Linux?.
