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

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!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel