1

I have a server on digitalocean and I want to connect it to git. (not even push anything, just connect).

When I test my connection with: ssh -T git@github.com.

I get an error of git@github.com: Permission denied (publickey). I have tried everything to try to make the connection work. On my computer the connection works, and the key on my root server is linked to my local id_rsa. The key is the same and I checked this with ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub on both my server and computer.

I am following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-laravel-application-with-nginx-on-ubuntu-16-04

Any ideas? I am stuck and going insane.

Otto
  • 663
  • 3
  • 17
  • 33

2 Answers2

4

Recently I faced a similar issue on digital ocean.

  1. start the ssh-agent eval "$(ssh-agent -s)"
  2. add your private key ssh-add ~/.ssh/id_rsa

Hope this helps and that it is the cause of your problem.

Dino Numić
  • 1,414
  • 2
  • 9
  • 17
  • I have tried this a few times indeed. Nothing, still permission died. And the key that I am using is on my github under `keys`. – Otto Sep 06 '19 at 09:22
  • I am not able to do this in my specific user. `WARNING: UNPROTECTED PRIVATE KEY FILE!` `Permissions 0775 for '/home/deployer/.ssh/id_rsa' are too open.` – Otto Sep 06 '19 at 09:32
  • Well it kindly asks for stricter permissions on ssh keys. Something like ```sudo chmod 600 ~/.ssh/id_rsa sudo chmod 600 ~/.ssh/id_rsa.pub``` would do. – Dino Numić Sep 06 '19 at 09:41
2

You should add the public key created on your server on github.

Nicolás Alarcón Rapela
  • 2,714
  • 1
  • 18
  • 29
Josir
  • 1,282
  • 22
  • 35
  • 1
    Deployment keys would be better for security reasons, you can limit the use to one repo and restrict the actions to read-only. Adding it to your account keys isn't recommended for deployments. Checkout the following steps: https://stackoverflow.com/a/57638034/6310593 – MaartenDev Sep 05 '19 at 18:11
  • Ok I did this like 12 times, but today it worked after rebooting my system and adding a new key... I am happy now. thanks. – Otto Sep 06 '19 at 09:23