项目场景:
在linux Ubuntu系统下,使用scp命令从另一个服务器到本服务器之间进行文件传输。
问题描述
提示:这里描述项目中遇到的问题:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
SHA256:'一串字符'.
Please contact your system administrator.
Add correct host key in /home/tonnn/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/tonnn/.ssh/known_hosts:12
ECDSA host key for '外服务器IP' has changed and you have requested strict checking.
Host key verification failed.
原因分析:
提示:这里填写问题的分析:
百度后发现,是因为我之前把自己的阿里云服务器系统重装了一下,导致云服务器的ECDSA key
改变了,而目标服务器上/home/tonnn/.ssh/known_hosts
中留存的还是原先的ECDSA key
,导致Host key verification failed
.
解决方案:
清除目标服务器/home/tonnn/.ssh/known_hosts
中对应IP地址的ECDSA key
,然后添加新的。
使用ssh-keygen -R ip-address
命令,在其官网https://www.ssh.com/academy/ssh/keygen#command-and-option-summary
查看其作用,即为将known_hosts
文件中属于一个主机hostname
的所有key
都清除。
清除后,重新连接对应主机即可,服务器会记录新的ECDSA key
。