Question

cant connect via ssh pubkey when I re-installed ubuntu on my personal machine

I’ve added the pub key to the security setting in the droplet but whenever I try to ssh to my vm I get root@mydroplet.ip : Permission denied (publickey).


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.

alexdo
Site Moderator
Site Moderator badge
September 16, 2022

Hello @friendlyazureshrimp

Your previous ssh-key pair is no longer present on your personal machine and you’ll need to generate a new pair and then upload it to your droplet to fix the problem.

You can check our article on How to Set Up SSH Keys on Ubuntu 22.04 and How to Upload an SSH Public Key to an Existing Droplet

https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-22-04

https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/

You can access the droplet from the DigitalOcean console and then temporary enable the PasswordAuthentication on your droplet and access the droplet with a password to upload the ssh-key.

If you haven’t created new pair of keys you’ll need to do that first.

You can enable PasswordAuthentication for your Droplet by modifying your /etc/ssh/sshd_config file. Once set to Yes restart the SSH service and connect via an SSH client for a more stable connection. You can then modify your ~/.ssh/authorized_keys file to add the appropriate public key.

You can then upload the key using this command:

  1. ssh-copy-id -i ~/.ssh/mykey user@droplet

Hope that this helps! Regards