0

我在使用时遇到问题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/****$
4

1 回答 1

0

您需要在将执行的用户的 $HOME (~) 中配置和注册一个 ssh(公钥和私钥)密钥git pull origin master

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

正如 [Martin Nyolt 2在评论中添加的那样,请遵循有关 ssh 的 GitLab 文档,尤其是“提示:非默认 OpenSSH 密钥文件名或位置”部分。

于 2016-09-29T13:14:18.683 回答