I generally used PuTTY to remotely connect to Linux servers under Windows. Now that I’ve switched to macOS, I’ve discovered that the terminal included with macOS also supports remote connections, so there’s no need to download another SSH client.

Then, when I was installing 酸酸乳 on a VPS in Los Angeles, something went wrong, so I reset the system. The second time I connected via SSH, I encountered the following error:

$ ssh root@107.174.218.121
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:HDjXJvu0VYXWF+SKMZjSGn4FQmg/+w6eV9ljJvIXpx0.
Please contact your system administrator.
Add correct host key in /Users/ikxin/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/ikxin/.ssh/known_hosts:46
ECDSA host key for 107.174.218.120 has changed and you have requested strict checking.
Host key verification failed.

The general meaning is that host key verification failed because it does not match the key saved the first time. I never encountered this problem when using PuTTY, possibly because the mechanisms of the two are different. This problem generally occurs because the system was reset. When the system is reset, the key is regenerated, so it no longer matches.

The solution is also very simple: use ssh-keygen.

Enter the following in the terminal:

ssh-keygen -R 你要访问的 IP 地址

This resets the matching key for the IP address, and it also saves the old key in the known_hosts.old file.