본문 바로가기
🐧 Linux_이야기

[Linux] SSH 접속 안 될 때 확인

by gwon_s 2026. 1. 8.

VM에서 IP도 잘 나오고 네트워크도 연결된 것 같은데
PuTTY로 SSH 접속하면 타임아웃…
👉 이거 실습하다 보면 거의 한 번씩은 다 겪는 일

 

이번 글에서는
SSH 접속이 안 될 때, 어떤 순서로 확인하고 어떻게 해결했는지
정리해보겠습니다.


✅ STEP 1. VM IP 확인

 
ip addr

 

정상 예시:

inet 192.168.101.4/24 brd 192.168.101.255 scope global enp0s8

✔ IP가 없다면 → 네트워크 자체 문제
✔ IP가 있다면 → 다음 단계


✅ STEP 2. 네트워크 인터페이스 상태 확인

 
nmcli dev status

 

정상 상태:

DEVICE  TYPE      STATE      CONNECTION
enp0s3  ethernet  connected  enp0s3
enp0s8  ethernet  connected  enp0s8
lo      loopback  unmanaged  --
 

❌ disconnected, connected (externally) 상태면
VirtualBox 어댑터 또는 DHCP 문제 가능성


✅ STEP 3. SSH 서비스 상태 확인

 
systemctl status sshd

 

정상:

● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset>
   Active: active (running) since Thu 2026-01-08 08:20:15 KST; 18min ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 792 (sshd)
    Tasks: 1 (limit: 18642)
   Memory: 4.0M
   CGroup: /system.slice/sshd.service
           └─792 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-po>

 

❌ Active 상태가 inactive / not found 라면:

systemctl start sshd
systemctl enable sshd
 

✅ STEP 4. 방화벽 확인 (의외로 제일 흔함)

 
systemctl status firewalld

 

테스트 용도로는 일단 중지:

systemctl stop firewalld
systemctl disable firewalld

 

또는 SSH 포트만 허용:

firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload
 
 

✅ STEP 5. 22번 포트 리스닝 확인

 
ss -tnlp | grep 22

 

정상:

LISTEN 0      128          0.0.0.0:22        0.0.0.0:*    users:(("sshd",pid=792,fd=3))
LISTEN 0      128             [::]:22           [::]:*    users:(("sshd",pid=792,fd=4))

 출력 없으면 → sshd 문제


✅ STEP 6. /etc/ssh/sshd_config 설정 확인

1️⃣ PermitRootLogin 확인

서버 콘솔에 접속해서 아래 확인

vi /etc/ssh/sshd_config
.
.
PermitRootLogin no
또는
PermitRootLogin prohibit-password

❌ 이 상태면 비밀번호로 root 로그인 불가입니다.

 

🔹 권장

PermitRootLogin yes
systemctl restart sshd

수정 후 반드시 재시작

 

2️⃣ Password 인증 확인

vi /etc/ssh/sshd_config

 

Password 인증 자체가 막혀 있는 경우:

PasswordAuthentication no

 

비밀번호가 맞아도 PasswordAuthentication이 꺼져 있으면 실패합니다.

 

🔹 권장

PasswordAuthentication yes
systemctl restart sshd

✅ STEP 7. VirtualBox Host-Only 네트워크 설정 확인

📍 Host-Only Adapter 예시 (정상)

  • IPv4 주소: 192.168.101.1
  • 서브넷 마스크: 255.255.255.0
  • DHCP 서버: 활성화
    • 범위: 192.168.101.101 ~ 192.168.101.200

👉 호스트와 VM이 같은 대역인지 반드시 확인


✅ STEP 8. PuTTY 설정 확인

  • Host Name: 192.168.101.4
  • Port: 22
  • Connection Type: SSH

❌ NAT IP / 다른 대역 IP 입력하면 무조건 실패