linux ssh命令提示Host key verification failed

[root@localhost backups]# scp [email protected]:/data/gitlabData/backups/1539717714_2018_10_17_9.4.3_gitlab_backup.tar .
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
85:82:b1:58:20:21:a5:da:be:24:e8:14:9a:12:b2:d2.
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 172.xxx.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.

二、分析原因
用OpenSSH的人都知ssh會把你每個你訪問過計算機的公鑰(public key)都記錄在~/.ssh/known_hosts。當下次訪問相同計算機時,OpenSSH會覈對公鑰。如果公鑰不同,OpenSSH會發出警告,避免你受到DNS Hijack之類的攻擊。

SSH對主機的public_key的檢查等級是根據StrictHostKeyChecking變量來配置的。默認情況下,StrictHostKeyChecking=ask。
————————————————
版權聲明:本文爲CSDN博主「歐陽鵬」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/ouyang_peng/article/details/83115290

簡單說下它的三種配置值:

1、StrictHostKeyChecking=no
最不安全的級別,當然也沒有那麼多煩人的提示了,相對安全的內網時建議使用。如果連接server的key在本地不存在,那麼就自動添加到文件中(默認是known_hosts),並且給出一個警告。

2、StrictHostKeyChecking=ask
默認的級別,就是出現剛纔的提示了。如果連接和key不匹配,給出提示,並拒絕登錄。

3、StrictHostKeyChecking=yes
最安全的級別,如果連接與key不匹配,就拒絕連接,不會提示詳細信息。
————————————————
版權聲明:本文爲CSDN博主「歐陽鵬」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/ouyang_peng/article/details/83115290

 

解決方法:

當前服務器下,編輯~/.ssh/known_hosts文件,將對應要連接的服務器IP刪除即可

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章