使用 git 拉出问题

Issue using git pull

我在使用 sudo git pull origin master 时遇到问题,我生成了 SSH-KEY 并将它们添加到 Gitlab,但我的命令不起作用...

命令:

****:/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/****$

您需要在将执行 git pull origin master

的用户的 $HOME (~) 中配置并注册一个 ssh(public 和私有)密钥

如果你想使用 root(这不理想),那么 id_rsa.pub(和 id_rsa)应该在 /root/.ssh(和 the right permissions

作为[马丁·尼奥特2 adds in the comments, follow the GitLab documentation about ssh, especially the section "Tip: Non-default OpenSSH key file names or locations”。