Solve the problem of automatic disconnection after ssh login without operation after a period of time

1、echo $TMOUT

If the display is blank, it means that there is no setting, which is equal to the default value of 0. Generally, it should not time out. If it is greater than 0, you can set it to 0 in files such as /etc/profile.

Definition: TMOUT: If set to a value greater than zero, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive

2. Modify the /etc/ssh/sshd_config file , remove the comment symbols of ClientAliveInterval 0 and ClientAliveCountMax 3, and change the 0 corresponding to ClientAliveInterval to 60. ClientAliveInterval specifies the time interval for the server to request messages from the client, the default is 0, no Send. And ClientAliveInterval 60 means sending once every minute, and then the client responds, so that the long connection is maintained. ClientAliveCountMax, use the default value 3. ClientAliveCountMax means that the number of times the client does not respond after the server sends a request reaches a certain value, and it will automatically Disconnect. Under normal circumstances, the client will not fail to respond.

Finally, remember to execute /etc/init.d/sshd restart, otherwise the modification just now will not take effect

Guess you like

Origin blog.csdn.net/JOB66/article/details/108586401