SSH connection timeout does not automatically disconnect

Source: Internet
Author: User
Tags ssh server

Putty

Enable Putty KeepAlive

Putty, Connection, Seconds between keepalives (0 to turn off), default is 0, change to 60.

Change the configuration file for the SSH server/etc/ssh/sshd_config

CLIENTALIVEINTERVAL Specifies the time interval for server-side request messages to clients, which is 0 by default and not sent. The Clientaliveinterval 60 means that it is sent every minute, and then the client responds so that it remains long connected. The strange place here is: not the client actively initiates the request to keep the connection (such as Fterm, cterm, etc.), but requires the server to take the initiative first.

Also, for Clientalivecountmax, use the default value of 3. Clientalivecountmax indicates that the client does not respond to a certain number of times after the server makes a request, automatically disconnects, and normally, the client does not respond.

Clientalivecountmax

Sets the number of the client Alive messages (see below) which could be sent without sshd (8) receiving all messages back from th e-Client. If this threshold was reached while client alive messages was being sent, SSHD would disconnect the client, terminating the Ses-sion. It is important to note that the use of the client alive messages are very different from tcpkeepalive (below). The client alive messages is sent through the encrypted channel and therefore won't be spoofable. The TCP keepalive option enabled by Tcpkeepalive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection have become inactive.t He default value is 3. If Clientaliveinterval (see below) are set to, and Clientalivecountmax are left at the default, unresponsive SSH clients 'll is disconnected after approximately seconds. This option applies to Protocol version 2 only.

Clientaliveinterval

Sets a timeout interval in seconds after which if no data have been received from the client, sshd (8) would send a message t Hrough the encrypted channel to request a response from the client. The default is 0, indicating that these messages won't be sent to the client. This option applies to Protocol version 2 only.

Vim/etc/ssh/sshd_config

Find the Clientaliveinterval parameter if you do not add a line yourself.

The value of the Clientaliveinterval parameter is seconds, such as if you set it to 540, or 9 minutes.

Clientaliveinterval 540

For Clientalivecountmax

If you find that the client is not corresponding, then determine a time-out, this parameter sets the number of times allowed to timeout, such as 10.

Clientaliveinterval 540

Clientalivecountmax 10;

Represents the Allow timeout of 5,400 seconds = 90 minutes.

SSH connection timeout does not automatically disconnect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.