Featured image of post 【Linux】問題解決:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! (ssh 無法連線)

【Linux】問題解決:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! (ssh 無法連線)

前言

這是在使用 ssh 無法連線的解決辦法,出現類似以下的訊息

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
...
Please contact your system administrator.
...
Host key verification failed.

錯誤圖片範例

解決方法

方法一:重建 ssh key

ssh-keygen -R 192.168.0.1
  • 192.168.0.1: 可任意替換成你要的ip

方法二:直接修改 /root/.ssh/known_hosts 文件

vim  /root/.ssh/known_hosts

把出問題的刪掉!!!

方法三:「最暴力的」把 /root/.ssh/known_hosts 文件直接刪掉!!!

執行此指令前,請務必知道自己在幹嘛!!!
如果搞不清楚狀況就直接執行此指令,後果請自負!

sudo rm -rf  /root/.ssh/known_hosts

Reference