Question

How to cleanup SSH keys?

I restored my droplet to downgrade from 16.04 to 14.04. Ever since, my SSH keys are not working. I tried removing and recreating without success. I manually added the same new key on my local machine, my droplet, and updated the key via the control panel. What am I missing, or how do I clear everything out and recreate the keys? Thanks.


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.

Hi!

I would first check SSH config, it could be that somehow is wrong there and it’s ignoring keys. Open config file with you favorite editor:

  1. sudo nano /etc/ssh/sshd_config

Now verify that following settings are as this:

sshd_config - Important settings
PubkeyAuthentication yes
ChallengeResponseAuthentication no

Make sure it is set as above and it’s uncommented (doesn’t have # in beginning of line). If you changed something make sure you restart SSH:

  1. sudo service ssh restart

If you want to clean up all keys, you can delete ~/.ssh/authorized_keys, than you can try again. I recommend you to copy keys with ssh-copy-id if that’s possible.

This tutorial can be a good reading and I recommend it.

If you do manual way, you can verify file permissions:

  1. sudo chmod 700 ~/.ssh
  2. sudo chmod 600 .ssh/authorized_keys

Try DigitalOcean for free

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

Sign up

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.