【发布时间】:2016-11-05 22:01:15
【问题描述】:
我有一个公开回购,https://github.com/rlpowell/config。我曾经能够在没有任何 ssh 密钥(即来自 cron)的情况下运行 git pull,并且使用 git@github.com:rlpowell/config.git URL(即 SSH URL)可以正常工作。这不再有效,我不知道为什么,但它确实适用于我的两个朋友。
我希望能够在没有 ssh 密钥的情况下 git pull 一个公共 repo,或者至少了解为什么它对我不起作用而对其他人起作用。
这是一个朋友在尝试我的测试用例:
$ git clone git@github.com:rlpowell/config.git ; cd config ; (unset SSH_AUTH_SOCK ; ssh-add -l ; git pull )
Cloning into 'config'...
Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.
remote: Counting objects: 1061, done.
remote: Total 1061 (delta 0), reused 0 (delta 0), pack-reused 1061
Receiving objects: 100% (1061/1061), 544.42 KiB | 495.00 KiB/s, done.
Resolving deltas: 100% (632/632), done.
Checking connectivity... done.
Could not open a connection to your authentication agent.
Already up-to-date.
我也在做同样的事情:
$ git clone git@github.com:rlpowell/config.git ; cd config ; (unset SSH_AUTH_SOCK ; ssh-add -l ; git pull )
Cloning into 'config'...
remote: Counting objects: 1061, done.
remote: Total 1061 (delta 0), reused 0 (delta 0), pack-reused 1061
Receiving objects: 100% (1061/1061), 544.42 KiB | 0 bytes/s, done.
Resolving deltas: 100% (632/632), done.
Checking connectivity... done.
Could not open a connection to your authentication agent.
Enter passphrase for key '/home/rlpowell/.ssh/id_rsa':
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
(我在 ssh 密钥密码提示符处按回车键)。
在 repo 中,.git/config 是:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.com:rlpowell/config.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
而 git config -l 是:
$ git config -l
user.email=rlpowell@digitalkingdom.org
user.name=Robin Lee Powell
push.default=matching
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:rlpowell/config.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
git 版本是 2.5.5
strace 说实际运行 ssh 的东西是
ssh git@github.com git-upload-pack 'rlpowell/config.git'
【问题讨论】:
-
一种可能性是,由于某种原因,您在 GitHub 中的 SSH 密钥与您在本地拥有的密钥不同步。关注these instructions 在 GitHub 中更新您的密钥。
-
我认为您认为可以在没有密钥的情况下进行克隆/拉取的假设是错误的(请参阅docs)。看看你朋友得到的输出:
... Could not open a connection to your authentication agent. ...;这证明在这种情况下使用了 SSH 密钥。您的朋友可能只是在他们的密钥上没有密码。如果您不想进行身份验证,请考虑使用 HTTPS 协议。 -
我们检查了密码短语。我可以 git clone 没有钥匙,但不能拉。我的 2 个朋友可以克隆和拉取。我的一个朋友既不能克隆也不能拉动。有更深层次的事情发生。
-
如果我理解正确,SSH 总是执行身份验证,因此需要您的密钥。另外尝试临时重命名
~/.ssh目录或使用不同的用户帐户以确保没有任何干扰。 -
您可以尝试使用之前设置的
GIT_TRACE=2进行相同的两个会话吗? (git-scm.com/book/en/v2/…)