使用scp命令移動某一服務器的文件到另外的服務器時報出一下錯誤:
[root@bogon vm_sys1]# scp project.tar.gz root@172.31.0.90:/webdata/ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 00:76:4d:f0:26:a3:05:1e:d6:fd:e7:56:32:32:77:41. 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:8 RSA host key for 172.31.0.90 has changed and you have requested strict checking. Host key verification failed. lost connection
仔細分析了一下大概是因為172.31.0.90的主機密鑰改了,而本機使用的還是原來的公鑰與其匹配,因此會出現錯誤。有人問不是我們使用密碼么,嗯,原因是這樣,一旦使用本機ssh連接過目標機,則會在~/.ssh/know_hosts文件下生成目標機的公鑰,以便下次可以直接使用。所以,我們可以把該文件下172.31.0.90對應的公鑰刪除掉
vi ~/.ssh/know_hosts
刪除掉172.31.0.90那一行。