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的 ...
随机推荐
- js原型和构造函数混合模式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- mac中添加环境变量
sudo vi /etc/paths 来编辑 paths,将环境变量添加到 paths 中. vim 是一个编辑器,另外还有几个,如:Pico,Emacs.
- MVC4.0 使用Form认证,自定义登录页面路径Account/Login
使用MVC4.0的时候,一般遇到会员登录.注册功能,我们都会使用Form认证,给需要身份验证的Action进行授权(需要登录后才能访问的Action添加[Authorize]属性标签),登录.注册的时 ...
- What is the difference between position: static,relative,absolute,fixed
What is the difference between static,relative, absolute,fixed we can refer to this link: expand
- 关于Objective-C格式化处理相关规范
Objective-C格式字符串和C#有很大的差别,下面我们就来看看 在C#中我们可以这么做,简单例举几个: //格式化输出字符串 string word = "world"; s ...
- 一个Option请求引发的深度解析
在当前项目中,前端通过POST方式访问后端的REST接口时,发现两条请求记录,一条请求的Request Method为Options,另一条请求的Reuest Method为Post.想要解决这个疑惑 ...
- 在安卓3.0以下版本使用Fragment的注意事项
1. 按照网上的Fragment官网资料翻译来做一直有错: 10-03 02:43:13.971: E/AndroidRuntime(1921): java.lang.RuntimeException ...
- IOS常用加密GTMBase64
GTMDefines.h // // GTMDefines.h // // Copyright 2008 Google Inc. // // Licensed under the Apache Lic ...
- 关于Google+以及Facebook第三方登录实现的一点总结
简述 最近项目中有关于第三方登陆的需求,第三方Facebook以及Google +登录. 正好这几天把这个需求做得差不多了,收个尾,作为一个这方面之前基本从未涉及的小白,总结下开发流程以及过程中遇到的 ...
- Hibernate中启用日志
Problem How do you determine what SQL query is being executed by Hibernate? How can you see the Hibe ...