2016-09-29 64 views
0

我得到使用sudo git pull origin master一个问题,我产生了SSH密钥和我说他们Gitlab,但我的命令不起作用......问题使用Git拉

命令:

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

可能root的ssh没有被配置为在'〜/ .ssh'中使用你的用户密钥。 –

+0

好的,我该怎么办? – tonymx227

回答

0

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

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

为[马丁Nyolt 2在评论中补充说,按照GitLab documentation about ssh,尤其是部分 “Tip: Non-default OpenSSH key file names or locations”。

+0

或者,按照[gitlab指南](https://docs.gitlab.com/ce/ssh/README.html)部分的“非默认OpenSSH密钥文件名或位置”,设置root的SSH以使用其他用户的身份文件。但是肯定的是,使用另一个用户(也许'www'组中的'www_git')应该是第一步。 –

+0

@MartinNyolt我同意。我已将您的评论纳入答案中,以获得更多的知名度。 – VonC

+0

谢谢你的工作。 – tonymx227