I have the following error when I try to connect to my rpi over SSH:

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
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:1
  remove with:
  ssh-keygen -f "/root/.ssh/known_hosts" -R
ECDSA host key for has changed and you have requested strict checking.
Host key verification failed.

I have found posts online related to that issue. The commom solution seems to be that you need to delete some line in that file. In my case it's: ssh-keygen -f "/root/.ssh/known_hosts" -R

However that file doesn't exist in my case and I still can't login on my rpi.

How can I solve this issue?

  • Have you tried using sudo? I am assuming you are not logged in as root. sudo ssh-keygen -f "/root/.ssh/known_hosts" -R
    – joan
    Mar 18 '17 at 14:56
  • @joan yes I have, but still no such file.
    – traducerad
    Mar 18 '17 at 14:57
  • The host keys are in /etc/ssh I just had the same error. I copied the pub key that contained my PC name to my PC known_hosts file using a stick.
    – PaulF8080
    Mar 22 '17 at 0:50
  • You can use file manager. Go into the View menu and click on Show Hidden. Then all will be revealed. In the end, you will want to use the command it suggests.. Then next time you connect will be like the first time ever - it will ask you to accept the key from the other server. Either that, or if it was a duplicate entry causing the problem (such as giving it a name in your /etc/hosts file), it makes sense to remove the entry listed only by IP address.
    – SDsolar
    May 2 '17 at 19:57

That file is not on rpi 3 you are trying to connect to, but on the computer where you are trying to connect from (Ubuntu?). Just run

ssh-keygen -f "/root/.ssh/known_hosts" -R

on your computer. Not on the rpi.


When that error comes up you need to remove the offending ECDSA key in

/root/.ssh/known_hosts:1 by copying line:

"ssh-keygen -f "/root/.ssh/known_hosts" -R" in your command line(This file is on the remote computer).

Then press enter. It will then ask if you really want to do this.

Then type in yes(not just y or enter) and it will clear the key off your Pi and you can sign in again.

Of course if someone is eavesdropping on you all bets are off!!

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.