ssh 远程链接服务器,经常会超时的解决方法

ssh 远程链接服务器,经常会超时的解决办法
env redhat 5
ssh远程链接服务器,经常会超时的解决办法
[oracle@hadoop ~]$ Read from remote host 121.248.200.15: Connection reset by peer
Connection to 121.248.200.15 closed.
如果ssh client 窗口在几分钟内没有键盘操作的时候 会话就会超时断线,通过修改sshd的配置文件 能够让ssh server 发送“心跳”信号来维持持续链接,
打开服务器/etc/ssh/sshd_config 文件 最后添加一行
ClientAliveInterval 60 指定了服务器端向客户端请求消息的时间间隔, 默认是0, 不发送.而ClientAliveInterval 60表示每分钟发送一次, 然后客户端响应, 这样就保持长连接了
ClientAliveCountMax 1  表示服务器发送请求后,客户端没有响应的次数达到了一定的值,就会自动断开。

PS
引用

[oracle@hadoop ~]$ man sshd_config
ClientAliveCountMax
  Sets the number of client alive messages (see below) which may be sent with-out 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 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 an d 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 3.  If ClientAliveInterval (see below) is set to 15,  and  ClientAliveCountMax is left at the default, unresponsive ssh clients will be disconnected after approximately 45 seconds.

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.