ssh远程主机秘钥失效的解决方法

问题描述

A机器通过ssh-copy-id root@IP(B)添加了链接到B机器的ssh秘钥。但是某天,B机器的密码修改或者机器重装,此时,在A机器上再次ssh IP(B)会报类似如下错误

 ssh IP(B)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for kube-001 has changed,
and the key for the corresponding IP address 100.104.179.42
is unchanged. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Offending key for IP in /root/.ssh/known_hosts:7
  remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R 100.104.179.42
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
82:14:68:63:20:52:0a:05:08:47:c1:fc:59:dc:d2:00.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:4
  remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R kube-001
ECDSA host key for kube-001 has changed and you have requested strict checking.
Host key verification failed.
此时无法ssh到B,如果重新使用以下命令

ssh-copy-id root@IP(B)
会报错如下:

ssh-copy-id root@IP(B)
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.


解决方法

ssh-keygen -R IP(B)
提示如下表示成功

ssh-keygen -R IP(B)
# Host kube-002 found: line 4 type ECDSA
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值