By sending a “null packet” between the client and the server at a specified interval that is smaller than the timeout value, we can avoid SSH timeout. It doesn’t matter if the packet is sent from the client or the server, as long as there is some communication going on between the two.
ClientAliveInterval 120
ClientAliveCountMax 720
This will make the server send the clients a “null packet” every 120 seconds and not disconnect them until the client have been inactive for 720 intervals (120 seconds * 720 = 86400 seconds = 24 hours).
Check the value through command line ...
[root@oam network-scripts]# sshd -T | grep -i client
clientaliveinterval 120
clientalivecountmax 720
Linux Client:
If we are on Linux, you can edit your local SSH config file in ~/.ssh/ssh_config (or) /etc/ssh/ssh_config and add the following line:
ServerAliveInterval 120
This will send a “null packet” every 120 seconds on your SSH connections to keep them alive.
Windows clients:
Putty - On Windows (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).
Mobaxterm - You can check the "Enable SSH keepalive" box under "Settings" --> "Configuration" --> "SSH" tab.
Prevent SSH timeout on the server side:
Please add the following to your SSH daemon config in /etc/ssh/sshd_config on your servers to prevent the clients to time out – so they don’t have to modify their local SSH config:ClientAliveInterval 120
ClientAliveCountMax 720
This will make the server send the clients a “null packet” every 120 seconds and not disconnect them until the client have been inactive for 720 intervals (120 seconds * 720 = 86400 seconds = 24 hours).
Check the value through command line ...
[root@oam network-scripts]# sshd -T | grep -i client
clientaliveinterval 120
clientalivecountmax 720
Prevent SSH timeout on the client side:
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, do the following:Linux Client:
If we are on Linux, you can edit your local SSH config file in ~/.ssh/ssh_config (or) /etc/ssh/ssh_config and add the following line:
ServerAliveInterval 120
This will send a “null packet” every 120 seconds on your SSH connections to keep them alive.
Windows clients:
Putty - On Windows (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).
Mobaxterm - You can check the "Enable SSH keepalive" box under "Settings" --> "Configuration" --> "SSH" tab.
No comments:
Post a Comment