SSH 連線逾時斷線

記得已前在Fedora Core上也是有預過,ssh連線一段時間沒有回應被斷線的問題.
新的伺服器上線了,喚來ubuntu 14.04.1預設的配置也有同樣的問題.
找了一下解法,讓ssh固定一段時間送小封包來確認連線.Interval就是幾秒輪巡.
而CountMax則是最多沒有回應會重送幾次.簡單紀錄一下.

ClientAliveInterval 60
ClientAliveCountMax 3
UseDNS no

 
去”man sshd_config”詳細的說明:
 

     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 mes‐
             sages is very different from TCPKeepAlive (below).  The client
             alive messages are sent through the encrypted channel and there‐
             fore will not be spoofable.  The TCP keepalive option enabled by
             TCPKeepAlive is spoofable.  The client alive mechanism is valu‐
             able when the client or server depend on knowing when a connec‐
             tion has become inactive.

             The default value is 3.  If ClientAliveInterval (see below) is
             set to 15, and ClientAliveCountMax is left at the default, unre‐
             sponsive 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 ver‐
             sion 2 only.

     UseDNS  Specifies whether sshd(8) should look up the remote host name and
             check that the resolved host name for the remote IP address maps
             back to the very same IP address.  The default is “yes”.
Facebook Comments
Scottj Written by:

史考特 喜歡3C 愛拍照