【问题标题】:Unable to ssh push in pygit2无法在 pygit2 中进行 ssh 推送
【发布时间】:2014-07-03 17:03:08
【问题描述】:

我正在尝试使用 ssh 推送到使用 pygit2 的 github 存储库。 这是我不断收到的错误。
你能指出错误吗?

>>> sshcred = repo_.pygit2.credentials.Keypair('avckp','id_rsa.pub','id_rsa','')
>>> remo2.credentials=sshcred
##  remo2 is a remote object for the repo
>>> remo2.url
u'https://github.com/avckp/sansa-pygit.git'
>>> remo2.push_url = remo2.url
>>> remo2.push('refs/heads/master')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "pygit2/remote.py", line 301, in push
    check_error(err)
  File "pygit2/errors.py", line 57, in check_error
    raise GitError(message)
GitError: HTTP parser error: the on_headers_complete callback failed

【问题讨论】:

  • 为什么要给自己分配remo2.push_url
  • 这是一个错字。它是 remo2.push_url = remo2.url
  • 感谢您的指出。刚刚做了。
  • 你不是通过 ssh 推送,而是通过 HTTP 推送。
  • 这是一些 ssh url 开始的一种方式,但您只需要查看架构,它应该是 ssh://(或使用 scp 样式的 user@host:path)。此外,尝试使用avckp 向 GitHub 进行身份验证不会成功,因为这不是他们拥有的系统用户。您所指的 git@ 部分是用户名,在您的示例中您将使用不可用的用户名覆盖它。

标签: git ssh libgit2 pygit2


【解决方案1】:

Keypair 中的用户名应该是 'git',正如#428 所说。

应该是:

sshcred = repo_.pygit2.credentials.Keypair('git','/path/to/id_rsa.pub','/path/to/id_rsa','')
remo.crendentals = sshcred

然后再次尝试推送。

【讨论】:

    猜你喜欢
    • 2021-05-28
    • 1970-01-01
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 2017-06-25
    • 2011-05-20
    • 1970-01-01
    • 2015-11-20
    相关资源
    最近更新 更多