【问题标题】:Issue using git pull使用 git pull 的问题
【发布时间】:2016-09-29 12:42:35
【问题描述】:

我在使用 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/****$

【问题讨论】:

  • 可能 root 的 ssh 未配置为使用您在 ~/.ssh 中的用户密钥。
  • 好的,我该怎么办?

标签: git ssh gitlab ssh-keys ssh-keygen


【解决方案1】:

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

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

由于 [Martin Nyolt2 在 cmets 中添加,请关注 GitLab documentation about ssh,尤其是“Tip: Non-default OpenSSH key file names or locations”部分。

【讨论】:

  • 或者,按照gitlab guide's 部分“非默认 OpenSSH 密钥文件名或位置”,设置 root 的 SSH 以使用其他用户的身份文件。但毫无疑问,使用另一个用户(可能是www 组中的www_git)应该是第一步。
  • @MartinNyolt 我同意。我已将您的评论包含在答案中以提高知名度。
猜你喜欢
  • 2019-01-07
  • 2013-01-15
  • 2015-02-03
  • 2018-06-27
  • 1970-01-01
  • 1970-01-01
  • 2020-03-25
  • 2013-09-25
  • 2013-08-17
相关资源
最近更新 更多