Solve the Problem of disconnecting after an SSH Login that is idle for too long

Source: Internet
Author: User
Tags ssh server

When we connect to the server through a terminal, when the mouse and keyboard do not operate for a long time, the server will automatically disconnect, and we still need to re-connect, it feels very troublesome, summarize the solutions to this problem.
Method 1,
Modify the/etc/ssh/sshd_config configuration file and find clientalivecountmax (in minutes) to modify the value you want,
Execute service sshd reload
Method 2,
Find the. Ssh directory of the user. For example, the root user directory is:
/Root/. Ssh/
Create a config file in this directory
VI/root/. Ssh/config
Add the following sentence:
Serveraliveinterval 60
Save and exit. Restart the root user's shell, and then restart the SSH remote server,
It will not be disconnected due to a long operation. After adding this sentence, the SSH client will
Automatically communicates with the SSH server once in a certain period of time, so the operation will not be disconnected for a long time.
Method 3,
Modify the/etc/profile configuration file
# Vi/etc/profile
Added: tmout = 1800
In this way, logout is automatically triggered if no operation is performed in 30 minutes.
Method 4,
Use secondary CT to simulate the keyboard action, simulate a keyboard response within the idle time, save the following code as XXX, and then run it with secondary CT.
#! /Usr/bin/CT
Set timeout 60
Spawn SSH [email protected]
Interact {
Timeout 300 {send "\ x20 "}
}
CT xxx
Then press the prompt to enter the password. In this way, a space (\ x20) is automatically entered every 300 seconds. The specific time interval can be set based on the actual situation.
Method 5,
If you use a tool in Windows to connect, you can set
Securecrt: option --- terminal --- set the number of seconds to send a string or NO-OP protocol package in the idle state
Putty: putty-> connection-> seconds between keepalives (0 to turn off). The default value is 0, which is changed to 300.

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.