Solve SSH automatic disconnection problem

Source: Internet
Author: User
When connecting to a remote SSH service, there is often a long disconnect or no response (no keyboard input).
Overall, there are two ways:


1. Rely on the SSH client to send the heartbeat regularly.
Putty, SECURECRT, Xshell have this function, but are not insured.


In addition under Linux:

#打开
sudo vim/etc/ssh/ssh_config
# add
Serveraliveinterval 20
Serveralivecountmax 999


That is, every 20 seconds, a heartbeat is sent to the server. If more than 999 requests are not successfully sent, the connection to the server side is actively disconnected.

2, a more permanent method is: Change the server side, that is, the remote SSH.

# Open
sudo vim/etc/ssh/sshd_config
# add
Clientaliveinterval 30
Clientalivecountmax 6


Clientaliveinterval indicates how many seconds, the server sends the heartbeat to the client, yes, you read it right.


The following clientaliveinterval indicates that the client has been disconnected after the number of heartbeats that are not responding.

Therefore, the total allowable non-response time is 60*3=180 seconds.


Test effective






Solve SSH automatic disconnection problem

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.