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).
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!
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.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
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:
Hope that this helps! Regards