How to Keep Alive SSH Sessions
Many NAT firewalls time out idle sessions after a certain period of time to keep their trunks clean.
There are two options:
- We can tell the SSH client to send keepalive packets to the server
- We can make the SSH server keep alive all connections with its clients
The settings below will make the SSH client or server send a null packet to the other side every 300 seconds (5 minutes), and give up if it doesn’t receive any response after 2 tries, at which point the connection is likely to have been discarded anyway.
In your session properties, go to
Connection and under
Sending of null
packets to keep session active, set
Seconds between keepalives (0 to
turn off) to e.g. 300 (5 minutes).
To enable the keep alive system-wide, edit
To set the settings for a user only, edit
Insert the following in the appropriate file:
Host * ServerAliveInterval 300 ServerAliveCountMax 2
Add to the file
ClientAliveInterval 300 ClientAliveCountMax 2