Cannot upload ssh key to my Droplet from Windows OS and keep getting "permission denied (publickey)" error

January 11, 2019 264 views
Getting Started DigitalOcean Security Ubuntu 18.04

I have two computers, one OS Mac and one OS Windows. Using the Mac i managed to add the SSH public key and I can log into the droplet from the local machine terminal.
On the one using windows, however, everytime I try to log in it throws the error
"permission denied (publickey)".
I tried to follow the tutorials:
1) https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-putty/
2) https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/
Still, I cannot get through it.
For example, in the session https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/#manually
it says to paste the key with nano editor but when I try to paste it, some characters of the key are changed (encrypted?) and I do not want to manually copy and paste the key inside the text editor.
Also, I do not have in my local machine this file "cat ~/.ssh/id_rsa.pub". Is it simply referring to the Putty key saved as private after the creation which I already added to the account (but not to the droplet)?
Also, even from the droplet web console when I try to use the "ssh" command it throws the error "permission denied (publickey)" so I cannot really do anything.
What am I doing wrong? Where can I find a working tutorial?
Thanks in advance for the answers.
Enrico.

1 Answer

I think you managed to generate two keys, first one from you Mac and the second one from your Windows machine.

I would recommend to use the same private key (from your Mac) on both machines.

You can use multiple pub keys for the same user but is more to explain, but the short answer is to use the same PrivateKey from your Mac on Windows too.

  • How though? Should I edit the key itself?
    Because when I create the key with the mac has some "link" to the user since there is at the end of the key user@localdomain.

    Instead, when I create the key with Windows the key itself finishes only with numbers... It seems weird that is linked to my local machine.

    Sorry for late answer.

    Enrico.

Have another answer? Share your knowledge.