关注微信公众号:CodingTechWork,一起学习进步。
介绍
??在工作登录服务器,准备从服务器A拷贝东西至服务器B,使用scp -r dir/ user_name@ip:/dir1/dir2
命令时报错WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
报错信息
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:rOhHwolh2Wnq/GXsC0JShvrDXxxxxEU+RCc0ck0Bbg.
Please contact your system administrator.
Add correct host key in /home/xxx/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/xxx/.ssh/known_hosts:20
ECDSA host key for 10.xxx.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.
lost connection
解决问题
问题分析
??其实这个报错也可以从提示中看出来,说的是远程主机标识已经改变,出现这种问题原因可能就是因为服务器B重装过系统,那服务器A上之前访问服务器B而保存了标识证书,这次登陆的时候对比了一下之前的记录,发现变化了,校验不通过,就没法登录或者拷贝东西。
解决方案
??在服务器A上清除本地缓存了的服务器B证书;
ssh-keygen -R serverB-ip
其中serverB-ip
就是远程需要拷贝或者登录的ip地址;
如:
[linux-1]$ ssh-keygen -R 10.xxx.xxx.xxx
# Host 10.xxx.xxx.xxx found: line 20
/home/xxx/.ssh/known_hosts updated.
Original contents retained as /home/xxx/.ssh/known_hosts.old
Linux—scp或ssh出现WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!