DEV Community

Discussion on: DigitalOcean Permission denied (publickey)

Collapse
 
andrerpena profile image
André Pena

This article was very useful, but to help people coming from Google, this error (Permission denied (publickey)) also happens if your identity is not set correctly.

When you do ssh_keygen it will generate a new SSH key, which the default name is id_rsa. If your computer happens to have another key already, with another name, your identity might be set to that key.

You should edit ~/.ssh/config, and make sure IdentityFile is set to the correct private key

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa
Enter fullscreen mode Exit fullscreen mode
Collapse
 
hooloovoochimico profile image
Angelo Moroni

I solved using this solutions

Collapse
 
tcbutler320 profile image
Tyler Butler • Edited

Thanks for the quick solution! If your on a mac you wanna make this edit here /private/etc/ssh/ssh_config

Collapse
 
laurianoelmiroduarte profile image
Lauriano Elmiro Duarte • Edited

I lost my access to DigitalOcean,
this tip of yours was my salvation, change the file name to id_rsa

Thanks