Question

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:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
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.

Anybody?


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!

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.