WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! ---ssh登录失败

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! ---ssh登录失败

如果你也是删除了known_hosts中的IP后还是登不上,就可以直接跳到最下面的第1点,去检查你的报错信息了

MacPro登录阿里云服务器,在正常的输入命令后,突然蹦出了一个新的错误。
IP与Users文件名均用******隐去

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:QdI+j4REUOvCxYY/8pPKbyzhQdm1s0DRJ+kwRg35y8s.
Please contact your system administrator.
Add correct host key in /Users/*****/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/****/.ssh/known_hosts:1
ECDSA host key for **** has changed and you have requested strict checking.
Host key verification failed.

通过万能的搜索工具,发现这个原因是由于服务器在重装后,秘钥信息不一致,本地的秘钥信息失效,需要重新生成导致的!在整个报错的报文中,可以发现

Add correct host key in /Users/****/.ssh/known_hosts to get rid of this message.

因此,去known_hosts文件中,删除远程连接服务器IP对应的行即可
Offending ECDSA key in /Users/****/.ssh/known_hosts:1
我这里是known_hosts文件的第1行。
删除完成后,在尝试进行登录,当ssh提示

Are you sure you want to continue connecting (yes/no)?

输入yes,重新写入秘钥信息,就可以完成登录了!

写在最后:
1、我在删除了known_hosts文件中的对应内容后,依然还是连不上远程服务器。。。。最后发现报错内容出了变化。。。。

Add correct host key in /Users/xiongying/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/xiongying/.ssh/known_hosts2:1
ECDSA host key for 47.98.216.48 has changed and you have requested strict checking.

文件变为了known_hosts2:1,然后去了目录发现还有一个known_hosts2文件。。。。再删除其中的远程服务器IP相关秘钥,终于可以登录了,真是坑爹啊。
2、删除秘钥可以打开文件进行删除,也可以使用命令进行删除

ssh-keygen -R “你的远程服务器ip地址”

你可能感兴趣的:(Linux登录,Linux,ssh)