Can't login to my server with my SSH key

I created a new droplet and set it to use the usual SSH key on my account that I generated a long time ago with PuttyGen on Windows. I’m on a Mac now so I just copied over the PPK file thinking that I could use it to login. Turns out I can’t. I tried changing the permission of the file using chmod 600 but that didnt work. I went back to my Windows machine and used PuttyGen to convert the .ppk to an open ssh one. Same filename but with a .pem extension. I still can’t login to my server. Im geetting this:

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 [a long string of letters and numbers]
Please contact your system administrator.
Add correct host key in /Users/me/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/me/.ssh/known_hosts:1
ECDSA host key for IPADDRESS has changed and you have requested strict checking.

Host key verification failed.


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
April 18, 2020
Accepted Answer

Hi there @reyesjmf,

You could try using the ssh-keygen command to delete the invalid key from your known_hosts file. The command that you need to use would be:

  1. ssh-keygen -R "you server hostname or ip"

Let me know how it goes! Regards, Bobby

@bobbyiliev It worked like a charm! I ran your command and tried to connect with:

$ ssh -i myKey.pem root@IPADDRESS

I got an error that my file wasn’t accessible and got “Warning: Permanently added ‘IPADDRESS’ (ECDSA) to the list of known hosts. Permission denied”

I tried again by adding the file path this way:

$ ssh -i ~/.ssh/myKey.pem root@IPADRESS

This time I was able to login.

Thanks for the help!

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.