Hosting » DigitalOcean » How do I SSH into a DigitalOcean server after getting permission denied Publickey error?

How do I SSH into a DigitalOcean server after getting permission denied Publickey error?

Last updated on December 25, 2022 @ 4:23 am

If you are getting a “Permission denied (publickey)” error when trying to SSH into a DigitalOcean server, you will need to make sure that the public key associated with your account is properly set up.

To do this, you will need to generate a new public key and add it to your DigitalOcean account. You can do this by running the ssh-keygen command on your local machine.1, Generate SSH Key censored nameYou can access your generated SSH public key with this command                    “cat ~/.ssh/(filename).pub2.1 Access the ssh key censored nameAdd the resulting public key to your DigitalOcean account. Once you have done this, you should be able to successfully SSH into your DigitalOcean server.1. Add SSH public key in DigitalOceanYou can also try to fix the config file by accessing with this command              “vim /etc/ssh/sshd_config“, then change the following lines:

PermitRootLogin prohibit-password to PermitRootLogin yes
PasswordAuthentication no to PasswordAuthentication yes

If this doesn’t solve the error, you can try to delete content in the “authorized_keys file” and copy and paste your own public key content. To do this, go to your DigitalOean dashboard and click Launch console.4.1 Launch Droplet ConsoleThen enter the following command “vi ~/.ssh/authorized_keys6.1 Enter this command.Replace the content in the “authorized_keys file” and copy and paste your own public key content. 7.1 Add your own SSH public key

PRO TIP: If you are trying to SSH into a Digitalocean server and you get the “permission denied Publickey” error, it means that your public key is not set up correctly on the server. Make sure that you have copied your public key into the ~/.ssh/authorized_keys file on the server.
Morgan Bash

Morgan Bash

Technology enthusiast and Co-Founder of Women Coders SF.