tonymx227 tonymx227 - 10 months ago 44
Git Question

Issue using git pull

I get an issue using

sudo git pull origin master
, I generated a SSH-KEY and I added them on Gitlab, but my command doesn't work...

Commands :

****:/var/www/****$ cat ~/.ssh/
ssh-rsa AAAAB3NzaC1yc2EAAAADAQ****4rZZwQjt0VmJdb8zGQwcNMsYAZTCssjNw1UQZqTSUZRy8uK76W9h9kXsVgggAf1EgUKaxaKFFMF50TtugkdsSIGq4/ze9vYDrEVy4rc4aOTPuBNI9X01JRbvUdRtOajmC8WEq5NdLUwXCtg/Cga2uZ ****
****:/var/www/****$ sudo git pull origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Answer Source

You need to configure and register a ssh (public and private) key in the $HOME (~) of the user which will execute git pull origin master

If you want to use root (which is not ideal), then the (and id_rsa) should be in /root/.ssh (with the right permissions)

As [Martin Nyolt2 adds in the comments, follow the GitLab documentation about ssh, especially the section "Tip: Non-default OpenSSH key file names or locations".