Fixing offending key in SSH known hosts

Standard
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
75:ea:aa:ab:b0:c4:30:45:0d:1e:87:89:e2:29:fd:b3.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:1
RSA host key for 75.101.XXX.XXX has changed and you have requested strict checking.
Host key verification failed.

In the event the ip address of your server changes and you are using a private key there is a quick fix. From the example above you see that my offending key is “known_hosts:1” or key 1. To fix the error lets remove the line 1 of the known hosts. This solution was performed in CentOS 6.x using the sed command. The sed command is used for processing of files. Sed stands for Stream Editor which parses text files and used for making textual transformations to a file. The command is applied on the specified file on a line by line basis.

sed -i '1d' ~/.ssh/known_hosts

After running this command the offending key should be removed, and you should be prompted to add the new ip of the server to the known hosts.