[Solved] SSH WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

[email protected]:~# ssh-copy-id -i ~/.ssh/id_rsa.pub  [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/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: ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
ERROR: Someone could be eavesdropping on you right now (man-in-the-middle attack)!
ERROR: It is also possible that a host key has just been changed.
ERROR: The fingerprint for the ECDSA key sent by the remote host is
ERROR: SHA256:PO6FFmEQ9kOL1nodp3vLqVvCRW00Rhnn6cD9+SxbfbU.
ERROR: Please contact your system administrator.
ERROR: Add correct host key in /root/.ssh/known_hosts to get rid of this message.
ERROR: Offending ECDSA key in /root/.ssh/known_hosts:2
ERROR:   remove with:
ERROR:   ssh-keygen -f "/root/.ssh/known_hosts" -R "10.17.20.144"
ERROR: ECDSA host key for 10.17.20.144 has changed and you have requested strict checking.
ERROR: Host key verification failed.
​
### Solution Reassign the name of the file where the key is saved
[email protected]:~# ssh-keygen -f "/root/.ssh/known_hosts" -R 10.17.20.144
# Host 10.17.20.144 found: line 2
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old
[email protected]:~# ssh-copy-id -i ~/.ssh/id_rsa.pub  [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '10.17.20.144 (10.17.20.144)' can't be established.
ECDSA key fingerprint is SHA256:PO6FFmEQ9kOL1nodp3vLqVvCRW00Rhnn6cD9+SxbfbU.
Are you sure you want to continue connecting (yes/no)?yes
/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: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password: 
​
Number of key(s) added: 1
​
Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

SSH keygen command is used to generate, manage and transform authentication key for SSH. It supports RSA and DSA

SSH keygen (option)

-b: specify the length of the key. 
-e : read the private or public key file of openssh. 
-C: add comment. 
-f: specify the name of the file used to save the key. 
-i : reads the unencrypted ssh-v2 compatible private/public key file and then displays the openssh compatible private/public key on the standard output device. 
-l: display the fingerprint data of the public key file. 
-N: provide a new cipher. 
-P: provide the (old) cipher.
-q: silent mode. 
-t: specify the type of key to be created.


Read More: