电脑首次通过终端成功连接Linux设备后;更换设备,但IP不变,进行终端连接时产生如下报错:
bash@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:83EVp2xxxxxxxq2T1673aikbbi2Gh4sxxxxxxxxxx.
Please contact your system administrator.
Add correct host key in /Users/xxxx/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/xxxx/.ssh/known_hosts:13
Host key for [192.168.55.78]:3719 has changed and you have requested strict checking.
Host key verification failed.
bash@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
我的 ~/.ssh/known_hosts 文件中,记录了 IP 192.168.55.78(端口 3719)的旧的公钥 fingerprint(指纹),但目标主机现在给你发送了一个新的公钥,因此 SSH 报出警告,担心是被篡改或中间人攻击。
bashThe fingerprint for the ECDSA key sent by the remote host is
SHA256:83EVp2xxxxxxxq2T1673aikbbi2Gh4sxxxxxxxxxx.
Add correct host key in /Users/xxxx/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/xxxx/.ssh/known_hosts:13
Host key for [192.168.55.78]:3719 has changed and you have requested strict checking.
Host key verification failed.
| 原因 | 说明 |
|---|---|
| 目标主机重装过系统或 SSH 服务 | 公钥会变 |
| 主机更换了密钥对 | 也会导致 key 改变 |
| 本地连接过另一个不同的机器使用了相同的 IP(但其实不是同一主机) | 会误判为 key 被篡改 |
| 网络被劫持,可能是中间人攻击(MITM) | 极少见,但是 SSH 报警的目的 |
bashnano ~/.ssh/known_hosts
执行后会自动从 ~/.ssh/known_hosts 中删除对应行。然后再次连接:
bashssh -p 3719 [username]@192.168.55.78
你会看到提示:
bashAre you sure you want to continue connecting (yes/no/[fingerprint])?
输入 yes 后会将新的 key 加入到 known_hosts 文件中。
本文作者:精卫
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!