By Stephan Wijman

Many NAT firewalls time out idle sessions after a certain period of time to keep their trunks clean. Sometimes the interval between session drops is 24 hours, but on many commodity firewalls, connections are killed after as little as 300 seconds. To avoid having your SSH sessions become unresponsive after e.g. 5 minutes, you can do any of the following.

On Linux SSH server

Edit the file /etc/ssh/sshd_config and add the following 2 lines:

ClientAliveInterval 300
ClientAliveCountMax 2

and restart the SSH service.

On Linux client

Edit the file /etc/ssh/ssh_config (or on a user level ~/.ssh/config) and add the following 3 lines:

Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2

On Windows using PuTTY

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).

Stephan Wijman • 30 Articles

View Articles