我这里有一个奇怪的问题。我们的 Maven 发布插件失败,因为它无法将标签推送到 Git。以下失败:
git push ssh://PU0S:xL8q@git-eim.fg.com/u0r0-SS/workspace-proxy.git workspace-proxy-server-1.10.1
[ERROR] Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR]
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.
如果我远程进入机器并尝试使用表单的 URL 进行推送,我会得到同样的错误:
git push ssh://PU0S:xL8q@git-eim.fg.com/u0r0-SS/workspace-proxy.git
如果我只是使用定义的 Remote 推送,它会成功:
git push origin master
以上内容让我确定 .ssh
key 在机器上可用。为什么第一个表单会失败?
最佳答案
Any idea why the following command fails
git clone ssh://git-eim.fg.com/u0r0-SS/workspace-proxy.git
but the following succeedsssh://git@git-eim.fg.com/u0r0-SS/workspace-proxy.git
?
What is special aboutgit@
?
git@
表示将接收推送的用户将是 git。然后,身份验证由用于 ssh 的公钥管理。
这不同于 PU0S:xL8q
,它是一个用户名/密码,仅在使用 https url 时才需要。
对于 ssh url,您永远不会“像您一样”(PU0S)推送,而是作为在服务器端管理 git repos 的帐户推送。
这就是为什么,例如,你总是在 git@github.com
推送。
如果 git push origin master
成功,则意味着与名为“origin
”的远程关联的 url 格式正确。
通常 ssh://git@git-eim.fg.com/u0r0-SS/workspace-proxy.git
。
使用 git remote -v
检查,或者 since git 2.7 , 使用 git remote get-url origin
。
关于使用 SSH 并指定凭据时,Git 推送因公钥失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38134304/