๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

OS/๐Ÿง Linux

๐Ÿง Ubuntu * SSH ์ ‘์† ์œ ์ง€ ํ‚ค๊ธฐ

์›๊ฒฉ์œผ๋กœ ์ ‘์†์„ ํ•˜๋‹ค ๋ณด๋ฉด, ์ผ์ • ์‹œ๊ฐ„ ๋™์•ˆ ํ‚ค ์ž…๋ ฅ์ด ์—†์„ ๋•Œ ์›๊ฒฉ ์ ‘์†์ด ์ข…๋ฃŒ ๋œ๋‹ค.

๊ธธ๊ฒŒ๋Š” 24์‹œ๊ฐ„ ์งง๊ฒŒ๋Š” 300์ดˆ๋ฉด ์ ‘์†์ด ์ข…๋ฃŒ๋œ๋‹ค.

 

โ—† linux user ๋ชจ๋‘์—๊ฒŒ ์ ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด,

$ vi /etc/ssh/ssh_config

 

โ—† ์ง€๊ธˆ ์‚ฌ์šฉ์ค‘์ธ user์—๊ฒŒ๋งŒ ์ ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด,

$ vi ~/.ssh/config

 

๐Ÿ’ก ํŒŒ์ผ์„ ์ถ”๊ฐ€ ํ˜น์€ ์ˆ˜์ •ํ•ด ์ฃผ๋ฉด ๋˜๋Š”๋ฐ ๋งŒ์•ฝ์— ์œ„ ์œ„์น˜์— ํ•ด๋‹น ํŒŒ์ผ์ด ์—†๋‹ค๋ฉด ์ƒ์„ฑ ํ›„ ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ด ์ฃผ๋ฉด ๋œ๋‹ค.

 

Insert the following:

Host *
ServerAliveInterval 300
ServerAliveCountMax 2

์—ฌ๊ธฐ์„œ ServerAliveInterval์˜ ๋‹จ์œ„๋Š” sec์ด๋ฉฐ ServerAliveCountMax์˜ ๊ฐฏ์ˆ˜๋Š” ์‚ด์•„์žˆ๋‹ค๊ณ  ๋ณด๋‚ผ ๋ฉ”์‹œ์ง€์˜ ์ˆ˜ ์ด๋‹ค.

์ฆ‰, 300์ดˆ ๋‹จ์œ„๋กœ 2๊ฐœ์˜ ํŒจํ‚ท์„ ์„œ๋ฒ„์ธก์— ์•„์ง ์ ‘์†์ด ์œ ํšจํ•˜๋‹ค๋Š” ์˜๋ฏธ๋กœ ๋ณด๋‚ธ๋‹ค.

๋”๋ณด๊ธฐ

ServerAliveCountMax

Sets the number of server alive messages (see below) which may be sent without ssh(1) receiving any messages back from the server. If this threshold is reached while server alive messages are being sent, ssh will disconnect from the server, terminating the session. It is important to note that the use of server alive messages is very different from TCPKeepAlive (below). The server alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The server alive mechanism is valuable when the client or server depend on knowing when a connection has become inactive.

The default value is 3. If, for example, ServerAliveInterval (see below) is set to 15 and ServerAliveCountMax is left at the default, if the server becomes unresponsive, ssh will disconnect after approximately 45 seconds. This option applies to protocol version 2 only; in protocol version 1 there is no mechanism to request a response from the server to the server alive messages, so disconnection is the responsibility of the TCP stack.

ServerAliveInterval
Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent to the server, or 300 if the BatchMode option is set. This option applies to protocol version 2 only. ProtocolKeepAlives and SetupTimeOut are Debian-specific compatibility aliases for this option.

 

๋งŒ์•ฝ Open SHH ์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋ชจ๋“  ์—ฐ๊ฒฐ์„ ์œ ์ง€ํ•˜๋„๋ก ํ•˜๋ ค๋ฉด ์•„๋ž˜ ํŒŒ์ผ์— ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

$ vi /etc/ssh/sshd_config

 

Edit or Insert the following:

ClientAliveInterval 300
ClientAliveCountMax 2

SSH ํด๋ผ์ด์–ธํŠธ ๋˜๋Š” ์„œ๋ฒ„๊ฐ€ ์ƒ๋Œ€์—๊ฒŒ 300์ดˆ ๋‹จ์œ„๋กœ 2๋ฒˆ์˜ ์—ฐ๊ฒฐํ™•์ธ์„ ํ•ฉ๋‹ˆ๋‹ค.

2๋ฒˆ์˜ ์—ฐ๊ฒฐํ™•์ธ ๋•Œ ์‘๋‹ต์„ ๋ฐ›์ง€ ๋ชปํ•˜๋ฉด ์—ฐ๊ฒฐ์€ ๋Š์–ด์ง‘๋‹ˆ๋‹ค.

 

 


Thanks for