Increasing SSH Session Time in Linux

Increasing SSH Session Time in Linux

It happens that the execution of a remotely launched command in Linux can be delayed, but it is necessary to wait for its execution (by the way, using screen command can be very useful in this case), or you had to take your mind off and the SSH session fell off at that time. This often happened at my workplace, so I decided to increase the ssh session timeout on the server in order to keep both the connection and my own nerves.

On the Linux server in the configuration file /etc /ssh/sshd_config we write:

TCPKeepAlive yes
ClientAliveInterval 60
ClientAliveCountMax 180

TCPKeepAlive - set to "yes", so the server will periodically ping the client, checking if it is alive.

ClientAliveInterval - sets the ping interval for checking the status of the client (in seconds). The parameter works only for protocol version 2 (Protocol 2).

ClientAliveCountMax - the number of client pings.

Thus, in my example, the session timeout will be 180 * 60/60 = 180 minutes = 3 hours.

After changing the settings, do not forget to restart the ssh service:

service sshd restart


systemctl restart sshd.service

Вас заинтересует / Intresting for you:

How to pack a folder in tar.gz...
How to pack a folder in tar.gz... 446 views borisen Mon, 23 Sep 2019, 07:23:42