By default, ssh will be automatically dropped when it is not operated for a period of time. After checking the information, you will find that the following parameters can be modified to solve the disconnection problem.
# Vi/etc/ssh/sshd_config # TCPKEEP = YES # ClientAliveInterval 15 # ClientAliveCountMax 45
Restart sshd service
#/Etc/init. d/sshd restart
ClientAliveInterval sets the length of time in seconds. If no data is received from the client after such a long time,
Sshd sends an "alive" message to the client through the Secure Channel and waits for a response.
The default value 0 indicates that the "alive" message is not sent. This option is only valid for the SSH-2.
The maximum number of "alive" messages that ClientAliveCountMaxsshd can send before receiving any client response. The default value is 3.
When this limit is reached, sshd will force disconnect and close the session.
Note that the "alive" message is very different from the TCPKeepAlive message.
"Alive" messages are sent through encrypted connections, so they are not spoofed. However, TCPKeepAlive messages can be spoofed.
If the ClientAliveInterval is set to 15 and the ClientAliveCountMax is kept as the default value, the client that does not respond will be forcibly disconnected after 45 seconds. This directive can only be used for SSH-2 protocols.