Article Title: How to Solve ssh timeout disconnection. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
When using SSH Secure Shell to connect to Linux, if there is no operation in a few minutes, the connection will be disconnected and you must log on again. The same operation is repeated each time, which is annoying, this article summarizes two solutions.
Method 1: change the configuration file/etc/ssh/sshd_config of the ssh server.
ClientAliveInterval specifies the time interval for the server to request messages from the client. The default value is 0, and no message is sent. ClientAliveInterval 60 indicates that the request is sent once every minute, and then the client responds, so that the persistent connection is maintained. The strange thing here is that the client does not actively initiate a request to maintain the connection (such as FTerm and CTerm), but the server needs to take the initiative first.
In addition, for ClientAliveCountMax, use the default value 3. ClientAliveCountMax indicates that after the server sends a request, the client automatically disconnects when the number of times the client does not respond to a certain value. Normally, the client does not respond.
Sets the number of client alive messages (see below) which may be sent without sshd (8) Inserting ing any messages back from the client. if this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the ses-sion. it is important to note that the use of client alive messages is very different from TCPKeepAlive (below ). the client alive messages are sent through the encrypted channel and therefore will not be spoofable. the TCP keepalive option enabled by TCPKeepAlive is spoofable. the client alive mechanic is valuable when the client or server depend on knowing when a connection has become inactive. the default value is 3. if ClientAliveInterval (see below) is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. this option applies to protocol version 2 only.
Sets a timeout interval in seconds after which if no data has been received ed from the client, sshd (8) will send a message through the encrypted channel to request a response from the client. the default is 0, indicating that these messages will not be sent to the client. this option applies to protocol version 2 only.
Find the ClientAliveInterval parameter. If not, add a line.
The value of ClientAliveInterval is second. For example, if you set it to 540, It is 9 minutes.
If the client is found to have no corresponding value, a timeout is determined. This parameter sets the number of times that timeout is allowed, for example, 10.
The timeout value is 5400 seconds = 90 minutes.
Method 2: configure the client
1. ssh commands in linux
Then, find the ServerAliveInterval parameter in it. If you don't have one, add it yourself. The parameters have the same meaning and are in seconds, for example, 9 minutes:
Set anti-idle, as shown in
Enable putty keepalive
Putty-> Connection-> Seconds between keepalives (0 to turn off). The default value is 0, which is changed to 60.