How To Fix Offending key in ~/.ssh/known_hosts file

While trying to ssh into a box you may run in to the following error:
Offending key in ~/.ssh/known_hosts:6

This could mean a handful of things. Amongst some of those is a man-in-the-middle attack or, as in my case, the RSA key has changed, such as a new box taking the place of old IP address. To resolve this use the error message to help you in finding the offending line number, which is shown at the end. In this case it's line 6. To remove this line you can use `sed` with the following parameters:

$ sed -i '6d' ~/.ssh/known_hosts
Filed under: Linux Leave a comment
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.