Mote Zart
Mote Zart

Reputation: 960

Permission denied (publickey) - Digital Ocean

This is definetly a duplicate but I went through as many of the other answers as I could, I posted on the Digital ocean forum first, and I contacted DO support, and still I cannot access my server.

I tried:

  1. Used ssh-keygen and make a key called id_rsa3 (id_rsa works, but this is already taken). Adding the SSH key on creation to the DO dashboard via copy/paste. This method did not work. I destroyed the droplet and began again.
  2. Recreated new keys and did ssh-copy-id -i ~/.ssh/id_rsa3 root@MY-IP. Then did ssh -v -i ~/.ssh/id_rsa3 root@MY-IP to test. Permission denied (publickey). I destroyed the droplet and began again.
  3. Recreated new keys. Login into DO console and go to /etc/ssh/authorized_keys and paste in the public key that matches my local key. Then ssh -v -i ~/.ssh/id_rsa3 root@MY-IP to test. Still, Permission denied (publickey). Destroy droplet, try again.
  4. Created a ~/.ssh/config and tried to get the droplet to choose the correct key. Might be some syntax problems here. It runs the config, but does not get the correct key.

    Host sinatra_app HostName 206.***.***.*04 AddKeysToAgent yes UseKeychain yes User root PubKeyAuthentication yes IdentityFile ~/.ssh/id_rsa3 IdentitiesOnly yes

UPDATE: Destroyed droplet and added new keys. It asks me for a PW even with SSH. If I changed the PasswordAuthentication no it will then say Permission denied (publickey). So this is where I am stuck now. With access but cannot remove PW.

Upvotes: 2

Views: 7565

Answers (3)

Ali Qaderi
Ali Qaderi

Reputation: 471

To resolve this issue, follow these steps (this may be late, but I hope it helps someone):

  1. sudo nano /etc/ssh/sshd_config and uncomment PasswordAuthentication, setting it to yes.
  2. sudo ls /etc/ssh/sshd_config.d/*.conf to check for additional configuration files.
  3. sudo nano /etc/ssh/sshd_config.d/*.conf and update PasswordAuthentication to yes in any listed files (I had two such files).

Upvotes: 0

EDMOND GIHOZO
EDMOND GIHOZO

Reputation: 345

i had the same issue, and to solve it , you open digitalocean , open console as in web and login with your root password,

then sudo nano /etc/ssh/sshd_config and change PasswordAuthentication from no to yes save and restart by sudo service ssh restart

that's all.

Upvotes: 7

Mote Zart
Mote Zart

Reputation: 960

This is a better answer where I solved this properly. https://serverfault.com/questions/938870/rampant-permission-denied-publickey-mac

I solved this, very poorly. This is a sloppy way to get access. It still asks for PW even with SSH but at least there is no public key error. ~1. Destroy- Permission denied (publickey) droplet 2. Recreate-if this is not first droplet DO NOT add SSH key to control panel. It won't know which private key to connect to 3. Create- new key- ssh-keygen 4. Copy- new key to server- ssh-copy-id -i ~/.ssh/new_keyname root@MY-IP 5. Test- ssh -i ~/.ssh/new_keyname root@MY-IP~

But will still ask for PW. Turning off PW (in /etc/ssh/sshd_config => PasswordAuthentication no) means removes all PW access (I know it is not supposed to, but it still does. I mean, it removes SSH and PW access so there is no access). I had to reset the root PW from the control panel under access, or recreate the droplet

Upvotes: 0

Related Questions