When we connect to the server through a terminal, when the mouse and keyboard do not operate for a long time, the server will automatically disconnect, and we still need to re-connect, it feels very troublesome, summarize the solutions to this problem.
Method 1,
Modify the/etc/ssh/sshd_config configuration file and find clientalivecountmax (in minutes) to modify the value you want,
Execute service sshd reload
Method 2,
Find the. Ssh directory of the user. For example, the root user directory is:
/Root/. Ssh/
Create a config file in this directory
VI/root/. Ssh/config
Add the following sentence:
Serveraliveinterval 60
Save and exit. Restart the root user's shell, and then restart the SSH remote server,
It will not be disconnected due to a long operation. After adding this sentence, the SSH client will
Automatically communicates with the SSH server once in a certain period of time, so the operation will not be disconnected for a long time.
Method 3,
Modify the/etc/profile configuration file
# Vi/etc/profile
Added: tmout = 1800
In this way, logout is automatically triggered if no operation is performed in 30 minutes.
Method 4,
Use secondary CT to simulate the keyboard action, simulate a keyboard response within the idle time, save the following code as XXX, and then run it with secondary CT.
#! /Usr/bin/CT
Set timeout 60
Spawn SSH [email protected]
Interact {
Timeout 300 {send "\ x20 "}
}
CT xxx
Then press the prompt to enter the password. In this way, a space (\ x20) is automatically entered every 300 seconds. The specific time interval can be set based on the actual situation.
Method 5,
If you use a tool in Windows to connect, you can set
Securecrt: option --- terminal --- set the number of seconds to send a string or NO-OP protocol package in the idle state
Putty: putty-> connection-> seconds between keepalives (0 to turn off). The default value is 0, which is changed to 300.