I got this error.
can anyone help?

Add correct host key in /home/sam/.ssh/known_hosts to get rid of this message.
Offending key in /home/sam/.ssh/known_hosts:2
RSA host key for has changed and you have requested strict checking.
Host key verification failed.

4 Answers 4


The message means that the SSH key for the server you are trying to connect to has changed since the last time you connected there.

If that server was re-installed (or got its keys regenerated for some reason), all you need to do is edit your .ssh/known_hosts file and remove the offending line (the one that mentions that server). Make sure you check the key signature when you reconnect before you save it when SSH asks you to.

If the server was not touched however, you have an issue: your .ssh/known_host was corrupted somehow, or the server was compromised, or someone's trying to mount a man in the middle attack.


Just to be clear, ssh implements server authentication by verifying this key. This is a security measure. Before taking action to reset the key, you should make sure you are actually connecting to the machine you think you are. If your network were hacked, you could be ignoring evidence of that event.


Open the file, and delete the second line, and save it

vi /home/sam/.ssh/known_hosts +2
1 looks like an IP address of a machine in a home network. The most likely reason is that you've previously SSH'd to an other machine with the same IP assigned.

In that case, you can safely remove line 2 of ~/.ssh/known_hosts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.