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

Posted January 11, 2019 1.4k views
Getting StartedSecurityDigitalOceanUbuntu 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:
Still, I cannot get through it.
For example, in the session
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/”. 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.

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.

Submit an Answer
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.