ssh登陸提示"Host key verification failed."的解決方法

由于遠(yuǎn)程的子機服務(wù)器,重新安裝過,之前建立的信任機制無法使用,再次ssh 執(zhí)行scp操作,提示連接操作失敗,提示如下:

lost connection

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ 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 the RSA host key has just been changed.

The fingerprint for the RSA key sent by the remote host is

a8:e5:62:46:78:94:94:16:03:c8:ac:17:fc:ef:39:aa.

Please contact your system administrator.

Add correct host key in /root/.ssh/known_hosts to get rid of this message.

Offending key in /root/.ssh/known_hosts:46

RSA host key for 222.186.56.15* has changed and you have requested strict checking.

Host key verification failed.

原因是在主機子系統(tǒng)每次成功ssh連接遠(yuǎn)程操作,都會把你每個你訪問過計算機的公鑰(public key)都記錄在主機的目錄/root/.ssh的known_hosts下,當(dāng)下次訪問相同子機服務(wù)器時,會核對公鑰。如果公鑰不同,會發(fā)出警告,避免你受到DNS Hijack之類的攻擊。

ssh連接上,提示繼續(xù),輸入yes,會把連接子機的RSA添加到主機known hosts下,如下:

The authenticity of host '222.186.56.159 (222.186.56.15*)' can't be established.

RSA key fingerprint is a8:e5:62:46:78:94:94:16:03:c8:ac:17:fc:ef:39:aa.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '222.186.56.15* (RSA) to the list of known hosts.

解決方式:

cd /root/.ssh

vi known_hosts

找到對應(yīng)的子機ip的 ssh-rsa 刪除該行,退出保存known_hosts,重新執(zhí)行主機ssh連接子機,通過操作。

另外,建立主機和子機的信任機制操作:

A服務(wù)器:/root/.ssh/下

1、ssh-keygen -t rsa

2、cd /root/.shh/目錄下

id_rsa為密鑰; id_rsa.pub為公鑰

// 生成keys

cat id_rsa.pub >authorized_keys

scp B服務(wù)器的同目錄下,/root/.ssh/ 下,建立A->B的信任,A scp 文件到 B 不需要密碼

如果B->A建立信任,同樣操作B的文件,生成后,直接追加到keys,再copy到A服務(wù)器同目錄下。

cat id_rsa.pub >>authorized_keys

把A公鑰id_rsa.pub生成key copy到B服務(wù)器根目錄root/.ssh/下

------摘自 ssh登陸提示"Host key verification failed."的解決方法 - CSDN博客

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容