六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 56|回复: 0

如何避免SSH Secure Shell Client链接LINUX超时,自动断开?

[复制链接]

升级  17.33%

20

主题

20

主题

20

主题

秀才

Rank: 2

积分
76
 楼主| 发表于 2013-1-31 10:47:05 | 显示全部楼层 |阅读模式
<div class="text_content">转载自西安百翔网络 [ http://www.fly810.com/ ]
 
   很多新手在使用SSH Secure Shell Client的过程中,肯定经常会遇到当用SSH Secure Shell连接Linux时,如果几分钟没有任何操作,连接就会断开,提示server responded "connection closed"  。必须重新登陆才行,每次都重复相同的操作,很是烦人。


   一般修改两个地方可将这烦人的问题解决
 
   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、修改/etc/ssh/sshd_config文件,将 ClientAliveInterval 0和ClientAliveCountMax 3的注释符号去掉,将ClientAliveInterval对应的0改成60,ClientAliveInterval指定了服务器端向客户端请求消息 的时间间隔, 默认是0, 不发送.而ClientAliveInterval 60表示每分钟发送一次, 然后客户端响应, 这样就保持长连接了.ClientAliveCountMax, 使用默认值3即可.ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值, 就自动断开. 正常情况下, 客户端不会不响应.
 
   最后记得执行/etc/init.d/sshd restart 哦,否则刚才的修改是不会生效的。
 
   想参考更多,请输入man sshd_config了解更多信息
 
   大家这下明白了吧,是不是现在觉得很爽,在使用SSH Secure Shell Client链接LINUX的时候再也不会超时和自动断开了,也不会再出现烦人的 server responded "connection closed"  错误提示了,很开心吧!
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表