SSH登录Linux报错ECDSA host key for ip has changed如何解决?

LinuxSSH登录Linux报错ECDSA host key for ip has changed如何解决?已关闭评论3321

当我们使用ssh root@ip登录Linux服务器时,服务器报错:"ECDSA host key for ip has changed and you have requested strict checking. Host key verification failed."

aliyunbaike@aliyundeMacBook-Pro:~$ ssh root@47.74.190.156
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:Ms+BRn93GbOO1fwP6g1O+UwSRFv9KIUMGeoHDt70OfQ.
Please contact your system administrator.
Add correct host key in /Users/aliyunbaike/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/aliyunbaike/.ssh/known_hosts:6
ECDSA host key for 47.74.190.156 has changed and you have requested strict checking.
Host key verification failed.

问题分析

这是由于,ssh连接服务器时,如果之前连接过,ssh会默认保存该ip的连接协议信息,当我们再次访问此ip服务器时,ssh会自动匹配之前ssh保存的信息,由于我们的服务器做了更改,例如重装系统等操作,会导致本地保存的ssh信息失效,于是再次连接时就会出现上述错误。
另外,远程服务器的ssh服务被卸载重装或ssh相关数据(协议信息)被删除也会导致这个错误。文章源自新手站长-https://xinshouzhanzhang.com/identification-has-changed.html

如何解决?解决方案

删除本地known_hosts里面的缓存信息即可。命令:ssh-keygen -R "你的远程服务器ip地址"文章源自新手站长-https://xinshouzhanzhang.com/identification-has-changed.html

aliyunbaike@aliyundeMacBook-Pro:~$ ssh-keygen -R "47.74.190.156"

删除本地的ssh keygen信息后,再次通过ssh root@ip登录应该就不会报错了。文章源自新手站长-https://xinshouzhanzhang.com/identification-has-changed.html

注意:R是大写!文章源自新手站长-https://xinshouzhanzhang.com/identification-has-changed.html 文章源自新手站长-https://xinshouzhanzhang.com/identification-has-changed.html

【阿里云99元服务器】入口2核2G3M带宽、新老用户同享、99元/年续费到2027年

【腾讯云特价】:2核2G3M 88元一年、2核2G4M 108元1年 366元3年、2核4G5M 166元/年 566元3年、4核8G12M 446元一年 更多配置8核16G18M和16核32G28M 点我直达 >>

2023阿里云优惠活动:xinshouzhanzhang.com/go/aliyun

注意:以上特价轻量服务器限制条件为“产品首单特惠”,如果你的腾讯云账号已经是老用户,建议重新注册一个腾讯云账号,如果你是新用户符合条件,那么无脑入,确实值得。

 最后更新:2018-4-10
SSH

Windows支持SSH的方法安装OpenSSH即可搞定

Windows系统下默认不支持SSH命令,那么Linux运维在windows客户端下如何使用ssh命令呢?很简单,安装OpenSSH即可搞定,新手站长网分享win系统下安装OpneSSH支持SSH命令...