ssh超时断开的解决方法
当用SSH Secure Shell连接Linux时,如果几分钟没有任何操作,连接就会断开,必须重新登陆才行,每次都重复相同的操作,很是烦人,本文总结了两种解决的方法。
方法1:更改ssh服务器的配置文件/etc/ssh/sshd_config
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() 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 messages is very different from TCPKeepAlive (below).
The client alive messages are sent through the encrypted channel and therefore will not be spoofable.
The TCP keepalive option enabled by TCPKeepAlive is spoofable.
The client alive mechanism is valuable when the client or server depend on knowing when a connection has become inactive.The default value is .
If ClientAliveInterval (see below) is set to , and ClientAliveCountMax is left at the default,
unresponsive SSH clients will be disconnected after approximately seconds.
This option applies to protocol version only. ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client,
sshd() will send a message through the encrypted channel to request a response from the client.
The default is , indicating that these messages will not be sent to the client. This option applies to protocol version only.
vim /etc/ssh/sshd_config
找到ClientAliveInterval 参数,如果没有就自己加一行。
ClientAliveInterval 参数的数值是秒,比如你设置为540,就是9分钟.
ClientAliveInterval 540
对于ClientAliveCountMax
指如果发现客户端没有相应,则判断一次超时,这个参数设置允许超时的次数,比如10。
ClientAliveInterval 540
ClientAliveCountMax 10;
则代表允许超时 5400秒 = 90分钟。
方法2:配置客户端
1. linux下的ssh命令
vim /etc/ssh/ssh_config
然后找到里面的ServerAliveInterval 参数,如果没有你同样自己加一个就好了。参数意义相同,都是秒数,比如9分钟:
ServerAliveInterval 540
2. SecureCRT
设置反空闲,如下图所示

3 Putty
启用putty keepalive
putty -> Connection -> Seconds between keepalives ( 0 to turn off ),默认为0,改为60。
ssh超时断开的解决方法的更多相关文章
- 解决:Linux SSH Secure Shell(ssh) 超时断开的解决方法
转载:http://www.cnblogs.com/jifeng/archive/2011/06/25/2090118.html 修改/etc/ssh/sshd_config文件,找到 ClientA ...
- linux ssh 经常断开 的解决方法
1.现象 在linux ,用ssh进行远程连接时,经常会发生长时间后断线,或者是无响应,就像卡住的感觉(键盘输入不进去). 2.解决方法 在ssh客户端的linux设置 # sudo vim /etc ...
- SSH 超时断开连接解决办法
配置服务器端: vi /etc/ssh/sshd.conf ClientAliveInterval 120 #以秒为单位(可以改大些) ClientAliveCountMax 0 #发现客户端没有相应 ...
- SSH连接自动断开的解决方法(deb/rpm)
######### 修改后的: ## # tail -f -n 20 sshd_config#MaxStartups 10:30:60#Banner /etc/issue.net # Allow cl ...
- secureCRT自动断开的解决方法
转: secureCRT自动断开的解决方法 secureCRT自动断开的解决方法 在secureCRT上登录时,一段时间不用的话会自动断开,必须重新连接,有点麻烦. 有时候服务器端的 /etc/pro ...
- 因修改/etc/ssh权限导致的ssh不能连接异常解决方法
因修改/etc/ssh权限导致的ssh不能连接异常解决方法 现象: $ssh XXX@192.168.5.21 出现以下问题 Read from socket failed: Connection r ...
- CentOS6.5 ssh远程连接缓慢解决方法
UseDNS no GSSAPIAuthentication no 1.适用命令及方案如下:[远程连接及执行命令]ssh -p22 root@10.0.0.19ssh -p22 root@10.0.0 ...
- SSH连接LINUX乱码解决方法
1.vi /etc/sysconfig/i18n 将内容改为 LANG="zh_CN.GB18030" LANGUAGE="zh_CN.GB18030:zh_CN.GB2 ...
- 【转】bash: ssh: command not found解决方法(linux)
原文转自:http://www.cnblogs.com/ahauzyy/archive/2013/04/25/3043699.html 今天在搭建hadoop的开发环境中,用的是centsos6.0的 ...
随机推荐
- 用MSBuild和Jenkins搭建持续集成环境(2)
http://www.infoq.com/cn/articles/MSBuild-2 作者 Mustafa Saeed Haji Ali ,译者 李剑 发布于 2012年10月23日 | 注意: ...
- spring字符编码设置
<filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springf ...
- C语言编写的随机产生四则运算测试题
题目:编写一个四则运算测试题的程序,要求每道题都要随机产生 解题思路: 1.编写测试题,且为30道,就要用到循环函数,因此想到用for()函数 2.随机产生两个数,就想到用rand()函数. 注:1. ...
- The income statement
The income statement measures performance over some period of time,usually a quarter or a year.The ...
- 【转】GCC编译使用动态链接库
相关gcc参数:-l -L -shared -fPIC -static -c -o 原文地址:[脚本之家]http://www.jb51.net/article/34990.htm 根据链 ...
- ZOJ 3941 Kpop Music Party 贪心
题目链接: http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3941 题解: 先吧所给的区间合并,得到若干个独立的区间. 然后从左 ...
- hdu 1301 Jungle Roads 最小生成树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 The Head Elder of the tropical island of Lagrish ...
- opencv中的Bayes分类器应用实例
转载:http://blog.csdn.net/yang_xian521/article/details/6967515 PS:很多时候,我们并不需要特别精通某个理论,而且有的时候即便你非常精通,但是 ...
- livevent的几个问题
关于libevent的几个问题 1.他到底是如何保证这个套接字有效的 主线程去断开关闭套接字,主线程去调用buffwrite,在子线程收到客户端断开时,主线程延迟1分钟释放,这样保证子线程操作完该so ...
- GPU crash unmap page access
这类gpu crash是 texture 没有gpu address 调试方法 去看texture, texture state 里面allocateMemoryBlock...这里面有gpuadd ...