【发布时间】:2020-02-28 13:19:09
【问题描述】:
使用 https 我可以毫无问题地将本地存储库推送到我的 Bitbucket 存储库。但由于某种原因,使用 git 的 ssh 无法正常工作 - 即使我的 ssh 密钥似乎可以正常工作。
这是有效的 https:
$ git remote -v
origin https://<myName>@bitbucket.org/<myName>/<myRepo>.git (fetch)
origin https://<myName>@bitbucket.org/<myName>/<myRepo>.git (push)
这是不起作用的原始 url:(编辑:明确使用了 set-url。)
$ git remote set-url origin git@bitbucket.org:<myName>/<myRepo>.git
$ git remote -v
...
origin git@bitbucket.org:<myName>/<myRepo>.git (push)
它会产生可怕的错误:
$ git push -u origin --all
...
fatal: protocol error: bad line length character: logg
我意识到“logg”是较长错误消息的开头。在尝试阅读该消息时,我尝试过:
$ ssh git@bitbucket.org git-receive-pack <myName>/<myRepo>
但是在一条似乎没有帮助的消息之后,这会被锁定:
<a long hex string> refs/heads/masterreport-status delete-refs side-band-64k quiet atomic ofs-delta agent=git/2.10.5
0000
按了四次回车键终于返回:
fatal: protocol error: bad line length character:
(是的,没有指定字符。)
我的 ssh 密码似乎可以正常工作,但只是为了确认我尝试过:
$ ssh -vT git@bitbucket.org
这返回了一个很长的回复。接近尾声:
You can use git or hg to connect to Bitbucket. Shell access is disabled
没有任何成功,我尝试了我的原始网址的几种变体,包括:
...
origin ssh:git@bitbucket.org:<myName>/<myRepo>.git (push)
导致:
ssh: Could not resolve hostname ssh: nodename nor servname provided, or not known
fatal: Could not read from remote repository
这一切都清楚了吗? ssh 不应该在这里工作吗?我还能尝试什么?
【问题讨论】:
-
不清楚。如果您使用 git clone https url 进行克隆,那么 git push 也将使用 https 连接。如果要从 https 更改为 SSH,则必须设置 url。参考这个 - help.github.com/en/github/using-git/…
-
Bitbucket Cloud SSH 连接已断开:bitbucket.status.atlassian.com/incidents/jbvzjz4yldss — 现已解决。再试一次。
-
@rootkonda:是的 set-url 用于更改原始 url。该问题已被编辑以(希望)使这一点更清楚。
-
@phd:这是个有趣的消息,但 ssh 仍然无法从这方面工作。