阿里云或腾讯云出现 ssh连接提示 REMOTE HOST IDENTIFICATION HAS CHANGED! 错误

yufei       3 年, 3 月 前       573

解决办法很简单,就是删除本地 ~/.ssh/known_hosts 远程服务器对应的那栏

简单教程所在的服务器是非常古老的服务器,前几天刚好所要迁移下硬件,于是就顺手操作了。

看到网站访问正常,以为没啥事,结果今天要 ssh 登录的时候就出错了,错误如下

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 RSA key sent by the remote host is
SHA256:7dqJYnmt5Je1SBO/mkdr9RWPGHOOE/ckmrzDGyNnsYU.
Please contact your system administrator.
Add correct host key in /Users/yu/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/yu/.ssh/known_hosts:48
RSA host key for 121.199.51.137 has changed and you have requested strict checking.
Host key verification failed.

原因嘛,就是因为

SSH 会把我们访问过的每个远程计算机的公钥(public key)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告,避免你受到DNS Hijack之类的***。

既然找到原因了,那就好解决了,直接编辑 ~/.ssh/known_hosts,将需要连接的那个 IP 相关 rsa 信息删除即可。再次成功的话,它会将内容继续写入到 ~/.ssh/known_hosts

目前尚无回复
简单教程 = 简单教程,简单编程
简单教程 是一个关于技术和学习的地方
现在注册
已注册用户请 登入
关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.