問題描述:
在日常的運維中需要做ssh的免密登陸有提示如下的報錯內容:
[root@paas-harbor01 cce-v5.2.3]# ssh-copy-id 192.45.66.14
/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:4l9S3zapjMZ8LGiqzbLRUt7z0XFVrNxUw50/Aa+zm48.
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:14
ERROR: ECDSA host key for 192.45.66.14 has changed and you have requested strict checking.
ERROR: Host key verification failed.
根據報錯的內容及運維經驗:原因是因為之前有做過ssh免密登陸了,也就是/root/.ssh/known_hosts文件已經存在了該地址記錄了,經過確認,該主機是有重新安裝過系統的。導致了之前的數據丟失了。
解決方案:
既然知道原因就好辦了,只需要將/root/.ssh/known_hosts文件中的192.45.66.14的記錄刪除掉就可以了。
vim?/root/.ssh/known_hosts
刪除掉192.45.66.14開頭所在行的數據。
然后重新ssh-copy-id 192.45.66.14命令就可以了。