What should I do if the Linux system SSH timeout is disconnected?

  

On Linux systems, if SSH does not work for a long time, the request timeout will be automatically disconnected. How do you set it up so that the SSH connection does not automatically disconnect? The following small series will introduce you to the Linux SSH timeout automatic disconnection solution.

Solution:

Solve the problem of automatic disconnection by modifying the configuration in /etc/ssh/sshd_config. The following are the meanings of the two configuration items to be modified:

“ClientAliveInterval specifies the interval at which the server requests a message from the client. The default is 0, not sent. The ClientAliveInterval 60 means that it is sent once every minute, and then the client responds, so that the long connection is maintained. The strange thing here is that instead of the client actively initiating a request to keep a connection (such as FTerm, CTerm, etc.), the server needs to be active first.

In addition, as for ClientAliveCountMax, the default value of 3 can be used. ClientAliveCountMax means that the number of times the client does not respond after the server makes a request reaches a certain value and is automatically disconnected. Under normal circumstances, the client will not respond. “

1 View current configuration

grep“ClientAlive& rdquo; sshd_config

#ClientAliveInterval0

#ClientAliveCountMax3

2 Back up the original file< Br>

cp sshd_configsshd_config.bak

3 Modify the configuration file

sed-i “s/#ClientAliveInterval 0/ClientAliveInterval 60/g” sshd_config

sed - i “s/#ClientAliveCountMax3/ClientAliveCountMax 3/g” sshd_config

4 Verify the modification result

grep“ClientAlive& rdquo; sshd_config

diff sshd_configsshd_config.bak

5 Restart the service

service sshdrestart

The above is the solution to the Linux SSH timeout disconnection. Through the settings in this article, no matter whether SSH times out or not, it will not be disconnected. Need to be disconnected automatically and can be set back.

Copyright © Windows knowledge All Rights Reserved