ssh超时断开有什么解决方法?

3个月前 (01-08 05:15)阅读3回复0
xxhh
xxhh
  • 管理员
  • 注册排名4
  • 经验值145300
  • 级别管理员
  • 主题29060
  • 回复0
楼主

  办法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

(8) 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 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。

   This option applies to protocol version 2 only。

ClientAliveInterval

Sets a timeout interval in seconds after which if no data has been received from the client, sshd

(8) 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。

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。

0
回帖

ssh超时断开有什么解决方法? 期待您的回复!

取消