Linux/공통
SSH 접속시 RSA 공유키 충돌 문제 해결
bong2.
2021. 11. 10. 07:08
SSH 접속 시 아래와 같은 오류가 발생하며 접속되지 않는다.
[root@localhost ~]# ssh root@192.168.183.40
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:B5sHJ6l/BY43HFT1NIiEYqbnUh01oI39HLnI05+wiqw.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending RSA key in /root/.ssh/known_hosts:96
RSA host key for 192.168.183.40 has changed and you have requested strict checking.
Host key verification failed.
이유는 192.168.183.40이라는 IP로 기존에 접속한 적이 있는 서버와 RSA 공유키를 기 교환한 상태에서, 192.168.183.40 서버가 바뀌었기 때문이다.
이 경우는 VM을 Copy하여 사용하던 중 같은 IP를 쓰게 된 상황이다.
아래 명령어를 사용하여 초기화 후 접속하면 된다.
# ssh-keygen -R [IP or DomainName]
[root@localhost ~]# ssh-keygen -R 192.168.183.40
# Host 192.168.183.40 found: line 96
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old
위 명령어 수행 결과, SSH 접속 정상 동작함을 확인 가능하다.
[root@localhost ~]# ssh root@192.168.183.40
The authenticity of host '192.168.183.40 (192.168.183.40)' can't be established.
RSA key fingerprint is SHA256:B******/B*********************************w.
RSA key fingerprint is M*************************************************2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.183.40' (RSA) to the list of known hosts.
root@192.168.183.40's password:
Last login: Wed Nov 10 00:37:45 2021 from xxx.xxx.xxx.xxx
만약 초기화를 하지 않고, 단순히 경고만 무시하고자 한다면 아래 옵션을 사용하면 된다.
# -o "StrictHostKeyChecking no"