Resolve the problem of automatic disconnection by modifying the configuration in/etc/ssh/sshd_config. The following are the meanings of the two configuration items that you want to modify:
"Clientaliveinterval specifies a server-side time interval for requesting messages from the client, which defaults to 0 and does not send. and Clientaliveinterval 60 is sent every minute, then the client responds, so the long connection is maintained. Here's the weird part: Not the client initiates the request to maintain the connection (such as Fterm, cterm, etc.), but requires the server to take the initiative first.
In addition, as for Clientalivecountmax, the default value of 3 can be used. Clientalivecountmax indicates that the number of times the client does not respond after a request has reached a certain value and is automatically disconnected. Under normal circumstances, the client will not be unresponsive. “
1 View current configuration
grep "Clientalive" Sshd_config
#ClientAliveInterval0
#ClientAliveCountMax3
2 Backing up the original file
CP Sshd_configsshd_config.bak
3 Modifying the configuration file
Sed-i "s/#ClientAliveInterval 0/clientaliveinterval 60/g" Sshd_config
Sed-i "s/#ClientAliveCountMax3/clientalivecountmax 3/g" Sshd_config
4 Verifying the modification results
grep "Clientalive" Sshd_config
Diff Sshd_configsshd_config.bak
5 Restart Service
Service Sshdrestart
The SSH client is not automatically disconnected for as long as it is idle.
reference materials
How to avoid SSH Secure Shell client link Linux timeout, automatic disconnect.
http://hbwanghai.blog.163.com/blog/static/1992971472012224105110918/
SSH timeout (SSH timeout) solution
http://www.yaozer.cn/ssh-%E8%B6%85%E6%97%B6ssh-timeout-%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/