Issue
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:
- 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. - Recreated new keys and did
ssh-copy-id -i ~/.ssh/id_rsa3 root@MY-IP
. Then didssh -v -i ~/.ssh/id_rsa3 root@MY-IP
to test.Permission denied (publickey).
I destroyed the droplet and began again. - 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. Thenssh -v -i ~/.ssh/id_rsa3 root@MY-IP
to test. Still,Permission denied (publickey).
Destroy droplet, try again. 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.
Solution
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
Answered By - Mote Zart Answer Checked By - Marilyn (WPSolving Volunteer)