linux学习问题之ssh连接异常

首先声明前提

VMware上安装过一次redhat8,并且设置网卡ip为192.168.122.1,当时是安装在移动硬盘上,因各种原因,后来在本地重新安装了一次redhat8,网卡设置的还是192.168.122.1,然后通过ssh连接,就无法连接了。

报错信息如下

C:\Users\86188\Desktop (master -> origin)
λ ssh -22 root@192.168.122.1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:WXJSvu5mKlAxUL2Quk9IQY9xD6hQfr66CSOC81nSJ/k.
Please contact your system administrator.
Add correct host key in C:\\Users\\86188/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\86188/.ssh/known_hosts:21
ECDSA host key for 192.168.122.1 has changed and you have requested strict checking.
Host key verification failed.

排查步骤:

经查询,得知,ssh连接都会记录一个ip以及对应的秘钥,来识别你所连接的服务器。我之前安装过一次redhat8,记录了192.168.122.1这个ip,并记录了对应的秘钥,结果我重新安装redhat8之后,IP没变,但是秘钥对不上,那就无法登陆了。

ssh连接,本地都会生成一个known_hosts这个文件,所以就需要对这个文件进行相应的修改。

解决方案:

清除你当前机器里关于你的远程服务器的缓存和公钥信息,注意是大写的字母“R”。

ssh-keygen -R 192.168.122.1
posted @ 2021-04-16 09:59  背着泰山找黄河  阅读(237)  评论(0编辑  收藏  举报