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

Troubleshoot

SSH ์ปค๋„ฅ์…˜ ๋ฌธ์ œ ์›์ธ ๋ฐ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•

๋ฐ˜์‘ํ˜•

SSH ์ปค๋„ฅ์…˜ ๋ฌธ์ œ(SSH Connectivity Issues)


SSH ํด๋ผ์ด์–ธํŠธ๋ฅผ ์ด์šฉํ•ด ์›๊ฒฉ ์„œ๋ฒ„์— ์ ‘์†ํ•˜๋ ค๊ณ  ํ•  ๋•Œ ์ด์Šˆ๊ฐ€ ์ƒ๊ธด๋‹ค๋ฉด, ์ฒซ ๋ฒˆ์งธ ๋‹จ๊ณ„๋Š” ์ด์Šˆ ์›์ธ์„ ์•„๋ž˜ 2๊ฐ€์ง€๋กœ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๋งŒ์ผ (2)์— ํ•ด๋‹นํ•œ๋‹ค๋ฉด ์žฌ๋ถ€ํŒ…์„ ํ†ตํ•ด ์ž์›์„ ์ผ์‹œ์ ์œผ๋กœ ํ•ด์ œํ•˜๊ฑฐ๋‚˜, ํ•˜๋“œ์›จ์–ด ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜, ๋ฃจํŠธ ๋ณผ๋ฅจ์„ ๋ณด์กฐ ๋””๋ฐ”์ด์Šค๋กœ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋Š” ๋ณต๊ตฌ์šฉ ์„œ๋ฒ„์™€ ๊ฐ™์ด ๋ณ„๋„๋กœ ์›์ธ์„ ๋ถ„์„ํ•  ์ˆ˜ ์žˆ๋Š” ํ™˜๊ฒฝ์ด ํ•„์š”ํ•˜๊ฒŒ ๋œ๋‹ค.

(1) ๊ธฐ๋ณธ์ ์ธ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ๋กœ ์ธํ•œ ๋ฌธ์ œ

  • ํ˜ธ์ŠคํŠธ ์ ‘๊ทผ์„ฑ ํ™•์ธ: ํ˜ธ์ŠคํŠธ๊ฐ€ ๋™์ž‘์ค‘์ด๊ณ  ๋„คํŠธ์›Œํฌ์— ์ž˜ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ์Œ
  • SSH ์„œ๋น„์Šค ํฌํŠธ ํ™•์ธ: SSH ์„œ๋น„์Šค๊ฐ€ ๊ธฐ๋ณธ ํฌํŠธ(22)๋ฅผ ์‚ฌ์šฉํ•˜๋Š”์ง€ ํ™•์ธ
  • ํ˜ธ์ŠคํŠธ ์ด๋ฆ„ ๋ฐ IP: ํ˜ธ์ŠคํŠธ ์ด๋ฆ„ ๋ฐ IP ์ฃผ์†Œ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ž…๋ ฅ๋จ
  • ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ ํ™•์ธ:
    ping hostname or ip
  • DNS ํ™•์ธ: ํ˜ธ์ŠคํŠธ๋ช…์„ ์‚ฌ์šฉํ•˜์—ฌ ์—ฐ๊ฒฐํ•˜๋Š” ๊ฒฝ์šฐ, DNS ์„œ๋ฒ„์—์„œ ํ˜ธ์ŠคํŠธ๋ช…์ด ์˜ฌ๋ฐ”๋ฅธ IP ์ฃผ์†Œ๋กœ ํ•ด๊ฒฐ๋˜๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.
    nslookup hostname
  • ๋กœ์ปฌ ๋ฐฉํ™”๋ฒฝ ํ™•์ธ: ํด๋ผ์ด์–ธํŠธ ์ธก์— ํ™œ์„ฑํ™” ๋˜์–ด์žˆ๋Š” ๋ฐฉํ™”๋ฒฝ ์œ ๋ฌด๋ฅผ ํ™•์ธํ•œ๋‹ค. ํ™œ์„ฑํ™” ๋˜์–ด ์žˆ์„ ๊ฒฝ์šฐ 22๋ฒˆ ํฌํŠธ ํ™•์ธ
  • MTU(MTU) ์„ค์ • ํ™•์ธ: ๊ฐ„ํ˜น MTU ์‚ฌ์ด์ฆˆ ์ด์Šˆ๋กœ ์ธํ•ด SSH ํ„ฐ๋„์ด ์ •์ƒ ๋™์ž‘ํ•˜์ง€ ๋ชปํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋Š” ๋“ฏ
    ip link show

    (2) ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ ์„ค์ •๊ณผ ๋ณ„๋„์˜ ๋ฌธ์ œ

  • ์†์ƒ๋œ ํŒŒ์ผ ์‹œ์Šคํ…œ(File system corruption)
  • ์ž˜๋ชป๋œ ํŒŒ์ผ ์‹œ์Šคํ…œ ๊ถŒํ•œ ๋ฐ ํŒŒ์ผ ์†Œ์œ ๊ถŒ(Wrong permission)
  • ๊ณ ์žฅ๋‚œ ์‹œ์Šคํ…œ ํŒจํ‚ค์ง€ ๋ฐ ํ•„์ˆ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
  • ํŠน์ • ํ”„๋กœ์„ธ์Šค์˜ CPU, Memory ๋“ฑ์˜ ์ž์› ๋ถ€ํ•˜ ๋ฐ ์šฉ๋Ÿ‰ ๋ถ€์กฑ
  • ํ•˜๋“œ์›จ์–ด ๋ฌธ์ œ(Droplet, Device failure)
  • Deprecated keypair hash ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฐ ํด๋ผ์ด์–ธํŠธ ๋ฒ„์ „ ์ด์Šˆ

๋””๋ฒ„๊น… ๋ ˆ๋ฒจ ์ƒํ–ฅ์„ ํ†ตํ•œ ์„ธ์…˜ ์ด๋ฒคํŠธ ๋กœ๊ทธ ์กฐํšŒ(ssh -vvv)


SSH ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๊ธฐ๋ณธ์ ์œผ๋กœ SSH ์„ธ์…˜์— ๋Œ€ํ•ด ์ œ๊ณตํ•˜๋Š” ์ •๋ณด ์ˆ˜์ค€์€ ๊ธฐ๋ณธ์ ์œผ๋กœ quiet ์ด๋ฏ€๋กœ ๋ฌธ์ œ๋ฅผ ๋””๋ฒ„๊น…ํ•  ๋•Œ๋Š” -verbose ์˜ต์…˜์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๋Œ€๋ถ€๋ถ„์˜ ๋ฌธ์ œ๋Š” ๋‹จ์ผ -v ์—์„œ๋„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์ง€๋งŒ -vvv๋Š” ๋ณด๋‹ค ์ƒํ–ฅ๋œ ์ถœ๋ ฅ ์ˆ˜์ค€์„ ์ œ๊ณตํ•˜๋ฏ€๋กœ ๋””๋ฒ„๊น… ์‹œ ๊ธฐ๋ณธ์ ์œผ๋กœ -vvv ์˜ต์…˜์„ ์ฃผ๋Š”๊ฒŒ ํŽธํ•˜๋‹ค. ssh -vvv ๋ช…๋ น์œผ๋กœ ์ถœ๋ ฅ๋˜๋Š” ์ผ๋ฐ˜์ ์ธ ๋‚ด์šฉ์—์„œ ๊ฐ ํ•„๋“œ๋ฅผ ํ•ด์„ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

์ข…ํ•ฉ์ ์ธ ์—ฐ๊ฒฐ ๊ณผ์ • ํ™•์ธ
์—ฐ๊ฒฐ ๊ณผ์ •์—์„œdebug1๋กœ ์‹œ์ž‘ํ•˜๋Š” ๊ฐ ๋ผ์ธ์„ ํ†ตํ•ด ์ „๋ฐ˜์ ์ธ ์—ฐ๊ฒฐ ์ƒํ™ฉ์„ ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ๋‹ค.

ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํ‚ค ํ™•์ธ
Offering public key: ... ๋˜๋Š” Offering password: ... ๋ถ€๋ถ„์—์„œ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ œ๊ณตํ•˜๋Š” ์ธ์ฆ ๋ฐฉ๋ฒ•์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์„œ๋ฒ„์—์„œ ํ—ˆ์šฉํ•˜๋Š” ์ธ์ฆ ๋ฐฉ๋ฒ• ํ™•์ธ
Authentications that can continue: ๋ถ€๋ถ„์—์„œ ์„œ๋ฒ„๊ฐ€ ํ—ˆ์šฉํ•˜๋Š” ์ธ์ฆ ๋ฐฉ๋ฒ•์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์„œ๋ฒ„๋กœ ์ „์†ก๋˜๋Š” ์œ ์ € ์ •๋ณด ํ™•์ธ
debug1: Sending SSH2_MSG_USERAUTH ๋ถ€๋ถ„์—์„œ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์„œ๋ฒ„๋กœ ๋ณด๋‚ด๋Š” ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ๋ฐ›์€ ๋ฉ”์‹œ์ง€ ํ™•์ธ
debug1: Remote protocol version ๋ถ€๋ถ„์—์„œ ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ๋ฐ›์€ SSH ํ”„๋กœํ† ์ฝœ ๋ฒ„์ „์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
debug1: SSH2_MSG_SERVICE_ACCEPT received ๋ถ€๋ถ„์—์„œ ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ์„œ๋น„์Šค ์ˆ˜๋ฝ ๋ฉ”์‹œ์ง€๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์„œ๋ฒ„ ํ‚ค ๊ตํ™˜๊ณผ์ • ํ™•์ธ
debug1: SSH2_MSG_KEXINIT ๋ฐ ์ด์— ๊ด€๋ จ๋œ ๋ถ€๋ถ„์—์„œ ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ ๊ฐ„์˜ ํ‚ค ๊ตํ™˜๊ณผ์ •์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์„œ๋ฒ„ ํ˜ธ์ŠคํŠธํ‚ค ํ™•์ธ
debug1: Server host key ๋ถ€๋ถ„์—์„œ ์„œ๋ฒ„์˜ ํ˜ธ์ŠคํŠธํ‚ค ์ •๋ณด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์•”ํ˜ธํ™” ๋ฐ ์••์ถ• ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ™•์ธ
debug1: kex: algorithm: ... ๋ฐ debug1: Compression ๋ถ€๋ถ„์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์•”ํ˜ธํ™” ๋ฐ ์••์ถ• ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

ssh -vvv๋ฅผ ์‚ฌ์šฉํ•œ ์ƒ˜ํ”Œ ์ถœ๋ ฅ๋‚ด์šฉ


$ ssh -vvv user@hostname  
OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f  31 Mar 2020  
debug1: Reading configuration data /etc/ssh/ssh_config  
debug1: /etc/ssh/ssh_config line 19: Applying options for *  
debug2: resolve_canonicalize: hostname hostname is address  
debug2: ssh_connect_direct  
debug1: Connecting to hostname [192.168.1.1] port 22.  
debug1: connect to address 192.168.1.1 port 22: Connection timed out  
ssh: connect to host hostname port 22: Connection timed out  

์œ„์™€ ๊ฐ™์€ ์ถœ๋ ฅ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ์ฃผ์š” ์‚ฌํ•ญ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

  1. OpenSSH ๋ฒ„์ „ ๋ฐ ์šด์˜์ฒด์ œ ์ •๋ณดOpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f 31 Mar 2020
  2. ํด๋ผ์ด์–ธํŠธ ์ธก SSH ์„ค์ • ํŒŒ์ผ ์ฝ๊ธฐ ํ™•์ธ debug1: Reading configuration data /etc/ssh/ssh_config
  3. ํ˜ธ์ŠคํŠธ ๋ฐ ํฌํŠธ ํ™•์ธ debug1: Connecting to hostname [192.168.1.1] port 22.
  4. ์—ฐ๊ฒฐ ์‹œ๋„ ์ค‘ ์—๋Ÿฌ ๋ฐœ์ƒ ํ™•์ธ debug1: connect to address 192.168.1.1 port 22: Connection timed out

์ด๋ ‡๊ฒŒ ์ถœ๋ ฅ๋œ ๋‚ด์šฉ์„ ํ†ตํ•ด ํด๋ผ์ด์–ธํŠธ๊ฐ€ ํ˜ธ์ŠคํŠธ์— ์—ฐ๊ฒฐ์„ ์‹œ๋„ํ•˜๋ฉด์„œ ๋ฐœ์ƒํ•œ ๋ฌธ์ œ๋ฅผ ์ถ”์ ํ•˜๊ณ , ๋””๋ฒ„๊น…ํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.

์ผ๋ฐ˜์ ์œผ๋กœ ๋งŽ์ด ๋ฐœ์ƒํ•˜๋Š” SSH ์—๋Ÿฌ๋ฉ”์‹œ์ง€


์ผ๋ฐ˜์ ์œผ๋กœ SSH ์ ‘์†์ด ๋ถˆ๊ฐ€ํ•  ๋•Œ ํ™•์ธํ•ด์•ผ ํ•˜๋Š” ๋ฉ”์‹œ์ง€๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

1. Authentication failure / Permission denied (publickey, password), Server refused our key
์ฃผ๋กœ ์ธ์ฆ์— ์‹คํŒจํ•œ ๊ฒฝ์šฐ์— ๊ด€ํ•œ ์ •๋ณด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ํ‚ค ๋˜๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ ์ธ์ฆ๊ณผ ๊ด€๋ จ๋œ ๋ฌธ์ œ๊ฐ€ ์—ฌ๊ธฐ์— ๋‚˜ํƒ€๋‚œ๋‹ค.

debug1: Authentications that can continue: publickey,password  
debug3: start over, passed a different list publickey,password  
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password  
debug3: authmethod_lookup publickey  
debug3: remaining preferred: keyboard-interactive,password  
debug3: authmethod_is_enabled publickey  

๋ฐ  

debug1: Offering public key: ~/.ssh/id_rsa RSA SHA256:xxxxxx  
debug3: send_pubkey_test  
debug2: we sent a publickey packet, wait for reply  
debug3: receive packet: type 51  
debug1: Authentications that can continue: publickey,password  
debug1: No more authentication methods to try.  
Permission denied (publickey,password).  

ํ™•์ธ ์‚ฌํ•ญ:

  • ์ธ์ฆ ๋ฐฉ๋ฒ• ํ™•์ธ: ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” ์ธ์ฆ ๋ฐฉ๋ฒ•์ด ์„œ๋ฒ„์—์„œ ํ—ˆ์šฉ๋˜๋Š”์ง€ ํ™•์ธํ•ด์•ผ ํ•œ๋‹ค.
  • ์œ„ ์˜ˆ์‹œ ๋กœ๊ทธ์—์„œ๋Š” debug1: Authentications that can continue: publickey,password ์ด๋ฏ€๋กœ ์„œ๋ฒ„๋Š” ํ˜„์žฌ ๊ณต๊ฐœํ‚ค ๋˜๋Š” ํŒจ์Šค์›Œ๋“œ ์ธ์ฆ์„ ํ—ˆ์šฉํ•˜๊ณ  ์žˆ์Œ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.
  • ๊ณต๊ฐœํ‚ค ํ™•์ธ: ํด๋ผ์ด์–ธํŠธ์˜ ๊ณต๊ฐœํ‚ค๊ฐ€ ์„œ๋ฒ„์— ๋“ฑ๋ก๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

ํ™•์ธ ๋ฐฉ๋ฒ•:
์„œ๋ฒ„ ์ธก ํ™•์ธ์ด ํ•„์š”ํ•˜๋ฏ€๋กœ ์„œ๋ฒ„์— ์ ‘์†ํ•˜๊ฑฐ๋‚˜ ์„œ๋ฒ„ ์ธก ๋ฃจํŠธ ๋ณผ๋ฅจ์„ ๋ถ„๋ฆฌํ•˜์—ฌ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์ด ์š”๊ตฌ๋œ๋‹ค.

  • ์„œ๋ฒ„ ์ธก SSH ์„ค์ • ํ™•์ธ: ์„œ๋ฒ„์˜ SSH ์„ค์ • ํŒŒ์ผ(/etc/ssh/sshd_config)์—์„œ PasswordAuthentication๊ณผ PubkeyAuthentication ์˜ต์…˜์ด yes ์ธ์ง€ ํ™•์ธ
  • ์„œ๋ฒ„์— ๋“ฑ๋ก๋œ ๊ณต๊ฐœํ‚ค ํ™•์ธ: ์„œ๋ฒ„์˜ ~/.ssh/authorized_keys ํŒŒ์ผ์—์„œ ํด๋ผ์ด์–ธํŠธ์˜ ๊ณต๊ฐœํ‚ค๊ฐ€ ๋“ฑ๋ก๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
  • ํด๋ผ์ด์–ธํŠธ ์ธก ๊ณต๊ฐœํ‚ค์™€ ์ผ์น˜ ์—ฌ๋ถ€ ํ™•์ธ: ํด๋ผ์ด์–ธํŠธ ์ธก์—์„œ ๋ณด์œ ํ•œ .pem ํŒŒ์ผ์— ๋Œ€ํ•ด ๊ณต๊ฐœํ‚ค๋ฅผ ํ™•์ธํ•˜๋ ค๋ฉด ssh-keygen -y -f <private.pem>

2. Connect to host port 22: Connection refused
ํ˜ธ์ŠคํŠธ์˜ SSH ํฌํŠธ์— ์—ฐ๊ฒฐํ•  ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ์˜ ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜ํƒ€๋‚˜๋ฉฐ, ํ˜ธ์ŠคํŠธ์—์„œ SSH ์„œ๋น„์Šค๊ฐ€ ์‹คํ–‰ ์ค‘์ด์ง€ ์•Š๊ฑฐ๋‚˜ ํฌํŠธ๊ฐ€ ์ œ๋Œ€๋กœ ์—ด๋ ค์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ์— ํ•ด๋‹น๋œ๋‹ค. Connection Refused ์—๋Ÿฌ๋Š” ํ˜ธ์ŠคํŠธ์—์„œ ์›๊ฒฉ์œผ๋กœ ์ „์†ก๋˜๋Š” ๋ฉ”์‹œ์ง€์ด๋‹ค.

ssh: connect to host example.com port 22: Connection refused  

ํ™•์ธ ์‚ฌํ•ญ:

  • SSH ์„œ๋น„์Šค ํ™•์ธ: ํ˜ธ์ŠคํŠธ์—์„œ SSH ์„œ๋น„์Šค ๋ฐ๋ชฌ(sshd)์ด ์ œ๋Œ€๋กœ ์‹คํ–‰ ์ค‘์ธ์ง€ ํ™•์ธ
  • ํฌํŠธ ํ™•์ธ: ํ˜ธ์ŠคํŠธ์˜ ๋ฐฉํ™”๋ฒฝ์ด๋‚˜ ๋„คํŠธ์›Œํฌ ์žฅ๋น„์—์„œ SSH ํฌํŠธ(๊ธฐ๋ณธ๊ฐ’ 22)์ด ์—ด๋ ค์žˆ๋Š”์ง€ ํ™•์ธ

ํ™•์ธ ๋ฐฉ๋ฒ•:

  • ์„œ๋ฒ„ SSH ์ƒํƒœ ํ™•์ธ: ํ˜ธ์ŠคํŠธ์—์„œ SSH ์„œ๋น„์Šค๊ฐ€ ๋™์ž‘ ์ค‘์ธ์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด sudo systemctl status sshd ๋˜๋Š” service sshd status๋ฅผ ์‚ฌ์šฉ
  • ํฌํŠธ ํ™•์ธ: ํ˜ธ์ŠคํŠธ์—์„œ sudo ss -tulpn | grep :22 ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ 22๋ฒˆ ํฌํŠธ๊ฐ€ ์—ด๋ ค ์žˆ๋Š”์ง€ ํ™•์ธ

3. Connect to host port 22: Connection Timedout
ssh: connect to host example.com port 22: Connectino Timedout ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋Š” SSH ํด๋ผ์ด์–ธํŠธ์—์„œ ๋ฐœ์ƒํ•˜๋ฉฐ, ์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ์— ์‘๋‹ตํ•˜์ง€ ์•Š์•„ ํด๋ผ์ด์–ธํŠธ ํ”„๋กœ๊ทธ๋žจ์ด ์ค‘๋‹จ(์ œํ•œ ์‹œ๊ฐ„ ์ดˆ๊ณผ)๋˜์—ˆ์Œ์„ ๋‚˜ํƒ€๋‚ธ๋‹ค.

ํ™•์ธ ์‚ฌํ•ญ:

  • ์ ‘์†ํ•˜๋ ค๋Š” IP ๋˜๋Š” ํ˜ธ์ŠคํŠธ ์ด๋ฆ„์ด ์ •ํ™•ํ•œ์ง€ ํ™•์ธ
  • ํ˜ธ์ŠคํŠธ์˜ ์ƒํƒœ๊ฐ€ ์ •์ƒ์ธ์ง€ ํ™•์ธ
  • SSH ํด๋ผ์ด์–ธํŠธ์™€ ํ˜ธ์ŠคํŠธ ๊ฐ„์˜ ์—ฐ๊ฒฐ์„ ์ฐจ๋‹จํ•˜๋Š” ๋ฐฉํ™”๋ฒฝ ์œ ๋ฌด ํ™•์ธ
  • ํ˜ธ์ŠคํŠธ ์ธก ๋ฐฉํ™”๋ฒฝ, Network ACL, TCP ๋ž˜ํผ์— ์˜ํ•œ SSH ํ”„๋กœํ† ์ฝœ ๋ฐ ํฌํŠธ ์ฐจ๋‹จ ํ™•์ธ

ํ™•์ธ ๋ฐฉ๋ฒ•:

  • (ํ˜ธ์ŠคํŠธ) TCP ๋ž˜ํผ: /etc/hosts.allow, /etc/hosts.deny
  • (ํ˜ธ์ŠคํŠธ) 22๋ฒˆ ํฌํŠธ ์ˆ˜์‹  ์—ฌ๋ถ€ ํ™•์ธ: sudo ss -tulpn | grep :22
  • (ํ˜ธ์ŠคํŠธ) ๋ฐฉํ™”๋ฒฝ ์—ฌ๋ถ€ ํ™•์ธ: sudo iptables -L ๋˜๋Š” (Ubuntu) sudo ufw status
  • (ํ˜ธ์ŠคํŠธ) nacl cat /etc/network/options

4. Host key verification failed
ํ˜ธ์ŠคํŠธ ํ‚ค ๊ฒ€์ฆ์— ์‹คํŒจํ•œ ๊ฒฝ์šฐ๋กœ ํ•ด๋‹น ํ˜ธ์ŠคํŠธ์˜ SSH ํ‚ค๊ฐ€ ์ด์ „์— ์ €์žฅ๋œ ๊ฒƒ๊ณผ ์ผ์น˜ํ•˜์ง€ ์•Š์„ ๋•Œ ๋‚˜ํƒ€๋‚œ๋‹ค. ๋ณด์•ˆ์ƒ์˜ ์ด์œ ๋กœ ์ด์ „์— ์ €์žฅ๋œ ํ˜ธ์ŠคํŠธ ํ‚ค์™€ ๋ณ€๊ฒฝ๋œ ํ‚ค๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์œผ๋ฉด ์—ฐ๊ฒฐ์„ ๊ฑฐ๋ถ€ํ•˜๊ฒŒ ๋œ๋‹ค.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  

ํ™•์ธ ์‚ฌํ•ญ:

  • ํ˜ธ์ŠคํŠธ ํ‚ค ๋ณ€๊ฒฝ ์—ฌ๋ถ€: ์ด์ „์— ์ €์žฅ๋œ ํ˜ธ์ŠคํŠธ ํ‚ค์™€ ํ˜„์žฌ ํ˜ธ์ŠคํŠธ ํ‚ค๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ, ํ˜ธ์ŠคํŠธ ํ‚ค๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ

ํ™•์ธ ๋ฐฉ๋ฒ•:

  • ํ˜ธ์ŠคํŠธ ํ‚ค ํ™•์ธ: ํด๋ผ์ด์–ธํŠธ์—์„œ ~/.ssh/known_hosts ํŒŒ์ผ์„ ์—ด์–ด ํ•ด๋‹น ํ˜ธ์ŠคํŠธ์˜ ํ‚ค๋ฅผ ํ™•์ธ
  • ํ˜ธ์ŠคํŠธ ํ‚ค ๊ฐฑ์‹ : ํ˜ธ์ŠคํŠธ ํ‚ค๊ฐ€ ๋ณ€๊ฒฝ๋œ ๊ฒฝ์šฐ, ssh-keygen -R <ํ˜ธ์ŠคํŠธ IP> ๋ช…๋ น์–ด๋กœ ๊ธฐ์กด ํ‚ค๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ๋‹ค์‹œ ์—ฐ๊ฒฐํ•˜์—ฌ ์ƒˆ๋กœ์šด ํ‚ค๋ฅผ ์ €์žฅ

5.Connection to port 22: no matching key exchange method found
ํ‚ค ๊ตํ™˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ์ธํ•œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ํ•ด๋‹น ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ์ฐพ์•„์„œ ์„œ๋ฒ„์—์„œ ํ—ˆ์šฉํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์—…๋ฐ์ดํŠธ ํ•ด์•ผํ•œ๋‹ค.

์˜ˆ์‹œ)

debug1: kex: algorithm: diffie-hellman-group14-sha1  
debug1: kex: host key algorithm: rsa-sha2-256  
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha1 compression: none  
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha1 compression: none  
debug3: send packet: type 30  
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY  
ssh_dispatch_run_fatal: Connection to <hostname> port 22: no matching key exchange method found  
  • debug1: kex: algorithm: diffie-hellman-group14-sha1: ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉํ•˜๋ ค๋Š” ํ‚ค ๊ตํ™˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜
  • debug1: kex: host key algorithm: rsa-sha2-256: ์„œ๋ฒ„์—์„œ ์‚ฌ์šฉํ•˜๋ ค๋Š” ํ˜ธ์ŠคํŠธ ํ‚ค ์•Œ๊ณ ๋ฆฌ์ฆ˜
  • ssh_dispatch_run_fatal: Connection to <hostname> port 22: no matching key exchange method found: ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„ ๊ฐ„์— ํ˜ธํ™˜๋˜๋Š” ํ‚ค ๊ตํ™˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์—†์–ด ์—ฐ๊ฒฐ์ด ์‹คํŒจ

์œ„์™€ ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” ํด๋ผ์ด์–ธํŠธ ์ธก์—์„œ ํŠน์ • ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉํ•˜๋Š”(์˜ˆ: sha1) ํ‚คํŽ˜์–ด๋ฅผ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ ๋ณด์•ˆ ๋ฐ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์—…๋ฐ์ดํŠธ ๋“ฑ์œผ๋กœ ์ธํ•ด ์„œ๋ฒ„ OS์—์„œ ํ•ด๋‹น ํ‚ค๋ฅผ ์ด์šฉํ•œ ์ ‘์†์„ ๊ฑฐ๋ถ€ํ•˜๊ฑฐ๋‚˜ ํ•  ๋•Œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.
ํด๋ผ์ด์–ธํŠธ๋‚˜ ์„œ๋ฒ„ ์ธก์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ํ‚ค ๊ตํ™˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜, ์„œ๋ฒ„ ์ธก์—์„œ ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉ ์ค‘์ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ—ˆ์šฉํ•˜๋„๋ก ์„ค์ •์„ ๋ณ€๊ฒฝํ•ด์•ผ ํ•œ๋‹ค. ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ด€๋ จ ์„ค์ •์€ ์„œ๋ฒ„์˜ sshd_config ํŒŒ์ผ์—์„œ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.
Ubuntu๋ฅผ ๊ธฐ์ค€์œผ๋กœ sshd_config ์—์„œ ์•„๋ž˜์™€ ๊ฐ™์€ ์„ค์ •์ด ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค.

# Ciphers and keying  
# RekeyLimit default none  

# Algorithms supported for protocol version 2  
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256  
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr  
MACs hmac-sha2-256,hmac-sha2-512,hmac-sha1  

์›ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ๊ธฐ์กด ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ˆ˜์ •ํ•œ๋‹ค. ์ฃผ์„ (#)์„ ์ œ๊ฑฐํ•˜๊ณ  ์›ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜, ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ฃผ์„ ์ฒ˜๋ฆฌํ•˜์—ฌ ๋น„ํ™œ์„ฑํ™”ํ•œ๋‹ค.
sha1 ์˜ ๊ฒฝ์šฐ OS์˜ ํŠน์ • ๋ฆด๋ฆฌ์Šค๋ถ€ํ„ฐ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ๋น„ํ—ˆ์šฉ ํ•˜๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์œผ๋ฏ€๋กœ ํ™•์ธ์ด ํ•„์š”ํ•˜๋‹ค.

๋ฐ˜์‘ํ˜•
Archives
Notice
Link
Visits
Today
Yesterday