Solve ssh automatic disconnection failure

  
 

vps has been using ssh management, but ssh will automatically drop the line if it is not operated for a period of time. After consulting the data, it is found that modifying the following parameters can solve the drop problem.


Add the following two lines to the /etc/ssh/sshd_config file: ClientAliveInterval 15ClientAliveCountMax 45 Restart the sshd service #/etc/init.d/sshd restart

ClientAliveInterval Settings A duration in seconds. If no data is received from the client for such a long time, sshd will send a ”alive" message to the client through the secure channel and wait for a response. The default value of 0 means no sending ”alive” messages. This option is only valid for SSH-2.

ClientAliveCountMax sshd The maximum number of 'alive" messages allowed to be sent before any client responses are received. The default is 3 . When this limit is reached, sshd will force the connection to close and close the session. It should be noted that the &alquo;alive” message is quite different from TCPKeepAlive. “alive” messages are sent over an encrypted connection, so they are not spoofed; TCPKeepAlive can be spoofed. If ClientAliveInterval is set to 15 and ClientAliveCountMax is left at the default value, the unacknowledged client will be forced to disconnect approximately 45 seconds later. This directive can only be used with the SSH-2 protocol.

Copyright © Windows knowledge All Rights Reserved