[SSHD] ssh 서버의 타임아웃 안되도록 설정 Computer Tip

매번 까먹어서 다시 정리합니다.

서버 쪽 /etc/ssh/sshd_config 에 다음 내용이 되어 있는지 확인합니다.

TCPKeepAlive no 
ClientAliveInterval 30
ClientAliveCountMax 240

다음은 위 항목에 대한 내용입니다.

         Specifies whether the system should send TCP keepalive messages to the other side.  If they are sent, death of the
         connection or crash of one of the machines will be properly noticed.  However, this means that connections will die
         if the route is down temporarily, and some people find it annoying.  On the other hand, if TCP keepalives are not
         sent, sessions may hang indefinitely on the server, leaving “ghost” users and consuming server resources.

         The default is “yes” (to send TCP keepalive messages), and the server will notice if the network goes down or the
         client host crashes.  This avoids infinitely hanging sessions.

         To disable TCP keepalive messages, the value should be set to “no”.

         This option was formerly called KeepAlive.

         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 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 mechanism is valu‐
         able 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 pro‐
         tocol version 2 only.

         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.

또한 ssh client 에 연결할 때,

~/.ssh/config 의 각 항목에

ServerAliveInterval 30

를 추가해 줍니다.

어느 분께는 도움 되셨기를 ..


댓글 입력 영역