问题描述:
Host机 ip地址发生变换导致客户机ssh无法访问host机,错误如下:
$ ssh XX@192.168.0.103
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:SdFQGwDlfRQhtEC9T2LaUAnRyTMGgCjVsStXdoinUtU.
Please contact your system administrator.
Add correct host key in /home/XX/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/XX/.ssh/known_hosts:1
remove with:
ssh-keygen -f "/home/XX/.ssh/known_hosts" -R "192.168.0.103"
ECDSA host key for 192.168.0.103 has changed and you have requested strict checking.
Host key verification failed.
解决方案:
在host机查询host机新的ip地址,假如查询后地址为192.168.0.103
在客户机按照如下操作
$ cd ~/.ssh
$ ll
-rw------- 1 jpma jpma 1679 5月 20 21:48 id_rsa
-rw-r--r-- 1 jpma jpma 404 5月 20 21:48 id_rsa.pub
-rw------- 1 jpma jpma 2438 5月 29 14:09 known_hosts
-rw-r--r-- 1 jpma jpma 1554 5月 20 19:48 known_hosts.old
$ rm known_hosts
$ ssh jpma@192.168.0.103
The authenticity of host '192.168.0.103 (192.168.0.103)' can't be established.
ECDSA key fingerprint is SHA256:SdFQGwDlfRQhtEC9T2LaUAnRyTMGgCjVsStXdoinUtU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.103' (ECDSA) to the list of known hosts.
jpma@192.168.0.103's password:
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-73-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
* Canonical Livepatch is available for installation.
- Reduce system reboots and improve kernel security. Activate at:
https://ubuntu.com/livepatch
389 packages can be updated.
1 update is a security update.
Your Hardware Enablement Stack (HWE) is supported until April 2023.
Last login: Sat May 22 23:22:21 2021 from 192.168.0.105
xhost: unable to open display ""