After I re-installed AlmaLinux Server on my old Intel NUC, I tried to connect to ssh. The system response message is an error below.
PS C:\Users\Chatr> ssh adminping@192.168.1.111 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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:CqeSzf6sCjCPp63H02E5BqXU7hfjE/YDW2uprgWwqic. Please contact your system administrator. Add correct host key in C:\\Users\\Chatr/.ssh/known_hosts to get rid of this message. Offending ECDSA key in C:\\Users\\Chatr/.ssh/known_hosts:6 Host key for 192.168.1.111 has changed and you have requested strict checking. Host key verification failed.
Why Host key verification failed!!!
- host key of the remote host was changed from
- man-in-the-middle attack
- Reinstall OS on the same machine, but you can backup >> how to backup/restore the host key in ssh server - Ask Ubuntu
- Note: Host key verification is process which make sure you are connecting to the host that you think you are connecting to
How to Fix "Host key verification failed"
Method 1 – removing old key by using the ssh-keygen command
- Syntax
ssh-keygen -R [hostname|IP address]
- Example (At Source Server)
PS C:\Users\Chatr> ssh-keygen -R 192.168.1.111 # Host 192.168.1.111 found: line 6 C:\Users\Chatr/.ssh/known_hosts updated. Original contents retained as C:\Users\Chatr/.ssh/known_hosts.old
Method 2 – manual removing old key
- Located known_hosts file (Source Server)
- for root is path /root/.ssh/known_hosts
- for non-root is path /home/<your user>/.ssh/known_hosts.
- bonus windows is path C:\Users\<your user>\.ssh\known_hosts
- Edit known_hosts file with text editor such as nano / vim / or vs code (GUI Mode) etc.
- delete records from known_hosts file and save.
Final Test ssh again
Reference
- Getting started with SSH security and configuration - IBM Developer
- how to backup/restore the host key in ssh server - Ask Ubuntu
- How Does SSH Work? {Detailed Overview} | pNAP KB (phoenixnap.com)
- What is SSH Protocol ❓ How does it work ❓ (wallarm.com)
- SSH Host Based Authentication (wallarm.com)
Discover more from naiwaen@DebuggingSoft
Subscribe to get the latest posts sent to your email.