0

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/id_rsa.pub
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.
****:/var/www/****$
tonymx227
  • 5,293
  • 16
  • 48
  • 91

1 Answers1

0

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 id_rsa.pub (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".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Alternatively, follow the [gitlab guide's](https://docs.gitlab.com/ce/ssh/README.html) section "Non-default OpenSSH key file names or locations", and set up root's SSH to use the other user's identity file. But definitely, using another user (maybe `www_git` in the `www` group) should be the first step. – Martin Nyolt Sep 29 '16 at 13:17
  • @MartinNyolt I agree. I have included your comment in the answer for more visibility. – VonC Sep 29 '16 at 13:20