我使用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/****$
答案 0 :(得分:0)
您需要在用户的$ HOME(〜)中配置并注册一个ssh(公共和私有)密钥,该密钥将执行git pull origin master
如果你想使用root(这不是理想的),那么id_rsa.pub
(和id_rsa
)应该在/root/.ssh
(the right permissions)
正如[Martin Nyolt 2在评论中添加的内容,请点击GitLab documentation about ssh,尤其是“Tip: Non-default OpenSSH key file names or locations”部分。