`
sunnylocus
  • 浏览: 870177 次
  • 性别: Icon_minigender_1
  • 来自: 美国图森
社区版块
存档分类
最新评论

ssh超时断开的解决方法

阅读更多

     当用SSH Secure Shell连接Linux时,如果几分钟没有任何操作,连接就会断开。必须重新登陆才行,每次都重复相同的操作,很是烦人,一般修改两个地方可将这烦人的问题解决

 

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表示服务器发出请求后客户端没有响应的次数达到一定值, 就自动断开. 正常情况下, 客户端不会不响应.

想参考更多,请输入man sshd_config了解更多信息

 

下面是man sshd_config获取的描述信息

 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 0, indicating that these messages will not be
             sent to the client.  This option applies to protocol version 2
             only.

 

    

 ClientAliveCountMax
             Sets the number of client alive messages (see above) which may
             be sent without sshd receiving any messages back from the
             client.  If this threshold is reached while client alive mes-
             sages are being sent, sshd will disconnect the client, terminat-
             ing the session.  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 mecha-
             nism is valuable when the client or server depend on knowing
             when a connection has become inactive.

             The default value is 3.  If ClientAliveInterval (above) is set
             to 15, and ClientAliveCountMax is left at the default, unrespon-
             sive ssh clients will be disconnected after approximately 45
             seconds.


             以上方法在Red Hat Enterprise Linux 4测试通过。

 

分享到:
评论

相关推荐

    ssh连接超时解决方法

    1.修改server端的etc/ssh/sshd_config 代码如下:ClientAliveInterval 60 #server每隔60秒发送一次请求给client,然后client响应,从而保持连接ClientAliveCountMax 3 #server发出请求后,客户端没有响应得次数达到3...

    Linux ssh远程连接断开问题处理办法解决

    我们在通过远程连接操作Linux server的时候,有可能过一段时间忘记操作,便会发生ssh断开的问题。 而如果是本地的server,比较好办,直连设备kill掉ssh,踢掉无效用户连接,再次链接即可,但如果是远程server的话,...

    树莓派首次使用自动配置

    启用root用户ssh连接,关闭ssh超时断开 #3,配置wifi的ssid和密码,需重启生效 #4,配置软件源并更新软件源 #5,安装ntfs-3g用以支持NTFS文件系统 #6,安装vim,并设置常用配置 #7,安装samba,并设置/media/pi/HD,...

    解决阿里云ssh远程连接短时间就会断掉的问题

    问题重现 阿里云服务器,使用Finalshell远程连接,在操作中没有出现任务异常,只要远程连接过程...问题解决 1. 打开sshd的配置文件 [root@ecs-c13b ~]# vim /etc/ssh/sshd_config 修改下面两行: 2. 修改如下参数 C

    mac下zoc7客户端

    mac上超级好用的ssh telnet客户端,支持各种编辑模式,文件上传和下载

    Solaris安全加固

    禁止 root 远程登录,限制 FTP 登录,关闭不必要的 inetd 服务,使用命令“cat /etc/ssh/sshd_config”查看...检查“Protocol”的值 (3)检查允许密码错误次数,超过后断开连接 检查“MaxAuthTries”的值,设置登录超时

    zARCHIVES.omxplayercamview.service-rpi-l:使用omxplayer进行raspbian-lite的简单systemd服务实现-开源

    b)启用/启动ssh服务器sudo systemctl启用ssh sudo systemctl start ssh注意:如果您未启用ssh服务器并且将相机设置为信息亭,则可能很难重置另一个相机视图,除非您断开网络连接或重新启动,这是由于持久服务的...

    NAT-TCP-test

    这样,我们可以发现NAT断开连接之前的超时时间。 测试将在启动时产生130个连接,并在1分钟后测试第一个连接,在2分钟后测试第二个,依此类推(共2小时10分钟)。 tcp-send-test可以做到这一点。

    排爆

    排爆RHEL7.x的整体EODRHEL 7问题修复应用程序超时问题: 编辑/ etc / ssh / sshd_config ClientAliveCountMax设置在没有sshd(8)接收到来自客户端的任何消息的情况下可以发送的客户端活动消息的数量(请参阅下文)...

    RouterOS2.9.6.with.crack及配置动画

    实现电信线路断开,自动切换到网通,网通线路断开自动走电信 2、多种网吧特需功有,如IP-MAC绑定,或是利用PPPOE-SERVER功能,解决ARP攻击问题;单IP限速,解决BT/QQ直播占用大量网络带宽,影响网速等问题 3、最精细...

    CuteFTP9简易汉化版

    连接Options-Set超时、重试和延迟值,连接限制,数据连接端口范围,在连接事件,和其他全球或per-Site连接相关的设置。 传输选项 标准Transfers-CuteFTP支持多个传输文件和文件夹的方法,包括键盘、鼠标、菜单和工具栏。...

    Linux FTP服务配置

    由于端口22被ssh服务器占用,所以需要关闭ssh服务并重启vsftp服务。 客户端用Flashfxp测试:新建站点"VsftpTest",输入Vsftp服务器的IP地址,端口填22,用户名填ftp1,密码填你设置的密码,然后点击"连接"按钮: 由于...

Global site tag (gtag.js) - Google Analytics