Increase SSH Connection Timeout
On the server, head over to the /etc/ssh/sshd_config
configuration file.
$ sudo vi /etc/ssh/sshd_config
Scroll and locate the following parameters:
#ClientIntervalAlive #ClientAliveCountMax
The ClientIntervalAlive
parameter specifies the time in seconds that the server will wait before sending a null packet to the client system to keep the connection alive.
On the other hand, the ClientAliveCountMax
parameter defines the number of client alive messages which are sent without getting any messages from the client. If this limit is reached while the messages are being sent, the sshd daemon will drop the session, effectively terminating the ssh session.
The timeout value is given by the product of the above parameters i.e.
Timeout value = ClientIntervalAlive * ClientAliveCountMax
For example, let’s say you have defined your parameters as shown:
ClientIntervalAlive 1200 ClientAliveCountMax 3
The Timeout value will be 1200 seconds * 3 = 3600 seconds. This is an equivalent of 1 hour, which implies that your ssh session will remain alive for idle time of 1 hour without dropping.
Alternatively, you can achieve the same result by specifying the ClientIntervalAlive
parameter alone.
ClientIntervalAlive 3600
Once done, reload the OpenSSH daemon for the changes to come into effect.
$ sudo systemctl reload sshd
Conclusion
As an SSH security measure, it’s always advisable not to set the SSH timeout value to a huge value. This is to prevent someone from walking by and hijacking your session when you are away for an extended period of time. And that’s it for this topic.
Comments
Post a Comment