解決SSH出現Host key verification failed error

報錯原因

       如果我們對某一臺服務器配置了root免密登錄, 然後將服務打包成了鏡像安裝到了另一臺服務器上, 再次使用ssh連接root賬號就會出現Host key verification failed.異常

報錯信息

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
SHA256:pb4C4NAkg4X2i72SAx3qnIUTGjion0N6RDClHXqa/Cc.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:5
ECDSA host key for 192.168.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.

解決方法

# 進入當前主機ssh數據所在目錄
[root@localhost .ssh]# cd ~/.ssh/
[root@localhost .ssh]# ls
authorized_keys  known_hosts  known_hosts.old

# 清除host數據
[root@localhost .ssh]# rm -f known_hosts

# 再次連接 
[root@localhost .ssh]# ssh [email protected]
The authenticity of host '192.168.xxx.xxx (192.168.xxx.xxx)' can't be established.
ECDSA key fingerprint is SHA256:pb4C4NAkg4X2i72SAx3qnIUTGjion0N6RDClHXqa/Cc.
ECDSA key fingerprint is MD5:8b:ac:05:34:b9:51:5a:5f:18:7c:f0:18:76:74:6e:2b.
Are you sure you want to continue connecting (yes/no)? yes
# 成功連接
[email protected]'s password:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章