Set the time for timeout closing when the server ssh remote connection

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
insert image description here
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.
insert image description here

2. After the modification is completed, restart the sshd service through the following command

systemctl restart sshd

Guess you like

Origin blog.csdn.net/weixin_43354152/article/details/130958865