How To Solve Host Key Verification Failed

How To Solve Host Key Verification Failed

這篇介紹How To Solve Host Key Verification Failed。

發生情境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
在Linux執行 ssh -p xxxxx root@yyyyy

出現以下訊息:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:/hYKEFk1s+6eLV4wPpfFcISsvZJY/g/LT6kxB/XaPEE.
Please contact your system administrator.
Add correct host key in /home/{username}/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/{username}/.ssh/known_hosts:19
ECDSA host key for [yyyyy]:xxxxx has changed and you have requested strict checking.
Host key verification failed.

解決方法

1
2
3
cd /home/{username}/.ssh/known_hosts
將登入的ssh -p xxxxx root@yyyyy 該行移除
即可正常ssh登入