When we remotely connect to the server through ssh, if the client is not used for a period of time, it will disconnect from the server. We can set the disconnection time by ourselves.
Taking the linux centos system as an example, the specific setting method is as follows:
1. Compile the sshd configuration file by the following command
vim /etc/ssh/sshd_config
Find the following two lines
ClientAliveInterval: Indicates how often the server sends a request to the client, the unit is s
ClientAliveCountMax indicates how many times the server does not receive a response from the client, it will disconnect.
Therefore, if the client does not operate for a long time, it will be disconnected The open time is:
ClientAliveInterval * ClientAliveCountMax
If you want to set the disconnection time, you need to remove the comments of these two lines and modify them.
For example, if you set ClientAliveInterval 60 and ClientAliveCountMax 30,
the disconnection time is 60 * 30 = 900s, that is, the client will be disconnected if there is no operation for 30 minutes.
2. After the modification is completed, restart the sshd service through the following command
systemctl restart sshd