In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to solve the SSH connection Linux timeout problem, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
In the course of development, you often need to log in to a remote server, so log in through ssh or putty, but as soon as you turn around, this guy is automatically disconnected. It is very exasperating, how to solve the problem that SSH connection is automatically disconnected after Linux timeout?
Modify server-related configuration
$TMOUT system environment variable
# use the following command to determine whether the parameter echo $TMOUT# is set. If the output is empty or 0 indicates no timeout The number n greater than 0 means timeout if there is no revenue in n seconds. # modify method vi / etc/profile#-- export TMOUT=900#-- # to change the above 900 to 0 is to set no timeout source / etc/profile# so that the configuration takes effect immediately
Sshd service configuration
Cd / etc/ssh# View the configuration of client activity status in sshd_config the default configuration of grep ClientAlive sshd_config# is as follows: #-# ClientAliveInterval 0#ClientAliveCountMax requests-- # ClientAliveInterval specifies the time interval for the server to request messages from the client The default is 0 and is not sent. A setting of 60 means that it is sent every minute, and then the client responds, thus maintaining a long connection. # ClientAliveCountMax means that when the number of times the client does not respond to a request from the server reaches a certain value, it will be disconnected automatically. Normally, the client will not be unresponsive, just use the default value of 3. # backup the original configuration file cp sshd_config sshd_config.bak# enable client activity check, check every 60 seconds, disconnect sed-I "s/#ClientAliveInterval 0/ClientAliveInterval 60max g" sshd_configsed-I "s/#ClientAliveCountMax 3/ClientAliveCountMax 3max g" sshd_config# to confirm the modification of grep ClientAlive sshd_config# comparison profile differences diff sshd_config sshd_config.bak# reload ssd configuration Let the configuration take effect service sshd reload modify the relevant configuration of the customer server
Login script
#! / usr/bin/expectset timeout 60spawn ssh user@host interact {timeout 300 {send "\ x20"} expect eof
A space (\ x20) is automatically typed every 300 seconds, and the specific time interval can be set according to the situation.
Windows configuration
If you connect through a tool under windows, you can set it to
SecureCRT: option-terminal-anti-idle setting how many seconds to send a string, or NO-OP protocol packet
Putty:putty-> Connection-> Seconds between keepalives (0 to turn off), default is 0, changed to 300.
The above content is how to solve the problem of SSH connection Linux timeout. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.