用putty/SecureCRT连续3分钟左右没有输入, 就自动断开, 然后必须重新登陆, 很麻烦.
在网上查了很多资料, 发现原因有多种, 环境变量TMOUT引起,ClientAliveCountMax和ClientAliveInterval设置问题或者甚至是防火墙的设置问题. 所以可以这么尝试:
1, echo $TMOUT
如果显示空白,表示没有设置, 等于使用默认值0, 一般情况下应该是不超时. 如果大于0, 可以在如/etc/profile之类文件中设置它为0.
Definition: TMOUT: If set to a value greater than zero, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive.
2. ClientAliveInterval 60
在/etc/ssh/sshd_config中增加ClientAliveInterval 60, ClientAliveInterval指定了服务器端向客户端请求消息的时间间隔, 默认是0, 不发送.而ClientAliveInterval 60表示每分钟发送一次, 然后客户端响应, 这样就保持长连接了.这里比较怪的地方是:不是客户端主动发起保持连接的请求(如FTerm, CTerm等),而是需要服务器先主动.
另外,至于ClientAliveCountMax, 使用默认值3即可.ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值, 就自动断开. 正常情况下, 客户端不会不响应.
ClientAliveCountMax
Sets the number of client alive messages (see below) which may be
sent without sshd(8) receiving any messages back from the client.
If this threshold is reached while client alive messages are
being sent, sshd will disconnect the client, terminating the ses-
sion. It is important to note that the use of client alive mes-
sages is very different from TCPKeepAlive (below). The client
alive messages are sent through the encrypted channel and there-
fore will not be spoofable. The TCP keepalive option enabled by
TCPKeepAlive is spoofable. The client alive mechanism is valu-
able when the client or server depend on knowing when a connec-
tion has become inactive.
The default value is 3. If ClientAliveInterval (see below) is
set to 15, and ClientAliveCountMax is left at the default, unre-
sponsive SSH clients will be disconnected after approximately 45
seconds. This option applies to protocol version 2 only.
ClientAliveInterval
Sets a timeout interval in seconds after which if no data has
been received from the client, sshd(8) will send a message
through the encrypted channel to request a response from the
client. The default is 0, indicating that these messages will
not be sent to the client. This option applies to protocol ver-
sion 2 only.
3. 启用putty keepalive
putty -> Connection -> Seconds between keepalives ( 0 to turn off ), 默认为0, 改为60.
4.SecureCRT设置反空闲
option->session option->Terminal->Anti-idle->Send protocol NO-OP every__seconds
每隔几秒发送空字符串 保持链接不断开
分享到:
相关推荐
ssh连接慢解决办法(成功) 用真机连接虚拟机卡的话: 1.进入虚拟机vim /etc/ssh/sshd_config 2.将 #UseDNS yes改为UseDNS no即可如下: 使用/UseDNS找到地方然后添加 #UseDNS yes UseDNS no #PidFile /var/run/sshd....
widnows自动登录ssh服务器自动执行命令的脚本
ssh自动连接脚本,使用了expect自动化交互以及mail邮件提醒功能。本人亲自实践,希望有助于大家。
通过xshell自动ssh登录,并执行命令
设置用户名密码后,ssh登录到另一台linux电脑,自动运行命令
Autossh 是一个用来监控 SSH 链接,并自动进行重连的工具。类似 rstunnel (Reliable SSH Tunnel),采用 C 语言开发,安装简单,特别适合多个主机的连接。
对于开发人员来说大多数时候都需要登录linux服务器,每次需要输入密码很是麻烦,shell脚本可以将每次输入验证步骤简化,只需要切换到脚本所在目录,输入“ ./ ssh_login.sh”即可实现自动登录
让你不再为配置SSH烦恼,很方便、快捷地生成SSH组合代码。可以提高工作效率。 目前版本支持Strtus+hibernate+spring+mysql 支持oracle与sqlserver的版本正在开发之中。 欢迎相互交流
就可以生成SSH框架,非常适合做开发,速度超快,有分页,有SQL语句自动生成,一般的查询 删除 添加 修改 更新 分页 过滤器都有,要的自己去下载,不多说 ,可能分数有点搞,这个不要注册码,网上的都不怎么好,不行...
主要介绍了详解xshell远程连接自动断开的问题解决办法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
SSH自动断开连接的原因和解决办法|SSH保持长连接方法
博文链接:https://zsp.iteye.com/blog/246859
是用ssh+Dwr的自动补全。我就用这样的方法做了一个例子。很好的用的一个补全方法,
1.vi /etc/sysconfig/i18n 将内容改为 ...2.安装LINUX的时候选择的是中文字,但是使用的时候出现了乱码解决方法是在命令提示下输入export LANG=C 3.export LC_ALL=zh_CN.GBK export LANG=zh_CN.GBK
树莓派开机需要的ssh(空文件即可)和wifi配置文件(需要自定义WiFi名称和密码),可直接复制进boot根目录。
ssh开发中遇到的一些小问题的解决办法,或许有能帮到你的也说不定
SSH+MySq demo 数据库自动创建
用ssh架构编写Web项目时,使用myEclipse的代码自动生成功能,很多时候不能满足我们的需要,很多时候需要手工写dao层,manager层,web层与及页面的代码,工作重复繁琐。 借助本工具结合myEclipse,不用写任何代码,就...
linux自动升级ssl&ssh脚本
groovy-ssh, 在 Groovy DSL上,基于SSH自动化工具 Groovy SSH是基于DSL的自动化工具,提供远程命令执行和文件传输。https://gradle-ssh-plugin.github.io捐赠这是一个在Apache许可以版 2.0下许可以的开源软件。 欢迎...