WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

爲了能讓容器(172.17.0.3)能通過ssh免密登錄宿主機,需要將宿主機上的公鑰複製到容器中,在宿主機中執行命令如下:

		    ssh-copy-id 172.17.0.3

但是執行命令時,提示如下錯誤:

[root@fanhao-test ~]# ssh-copy-id 172.17.0.3
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
ERROR: Someone could be eavesdropping on you right now (man-in-the-middle attack)!
ERROR: It is also possible that a host key has just been changed.
ERROR: The fingerprint for the ECDSA key sent by the remote host is
ERROR: SHA256:/oObhd2HdjsRl+O1Z0NZ4/CMgBzlf3+xnitJKb4ohN4.
ERROR: Please contact your system administrator.
ERROR: Add correct host key in /root/.ssh/known_hosts to get rid of this message.
ERROR: Offending ECDSA key in /root/.ssh/known_hosts:2
ERROR: ECDSA host key for 172.17.0.3 has changed and you have requested strict checking.
ERROR: Host key verification failed.

提示遠程容器中公鑰信息改變了,需要刪除掉舊信息,然後重新複製。

解決辦法:

刪除遠程中舊的公鑰信息,在宿主機中執行如下命令:

			ssh-keygen -R 172.17.0.3

然後重新把宿主機的公鑰複製到遠程容器172.17.0.3中,在宿主機中執行如下命令:

		    ssh-copy-id 172.17.0.3

最後提示copy成功:

[root@fanhao-test ~]# ssh-copy-id 172.17.0.3
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '172.17.0.3 (172.17.0.3)' can't be established.
ECDSA key fingerprint is SHA256:/oObhd2HdjsRl+O1Z0NZ4/CMgBzlf3+xnitJKb4ohN4.
ECDSA key fingerprint is MD5:bc:fd:bb:38:5b:d7:41:97:a8:02:aa:89:81:75:c5:c4.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '172.17.0.3'"
and check to make sure that only the key(s) you wanted were added.

至此問題解決。

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