【问题标题】:Cannot push into remote git repository无法推送到远程 git 存储库
【发布时间】:2018-06-24 04:18:49
【问题描述】:

我正在尝试让新开发人员访问我们的私有 git 存储库。先说几个前因:

  • 开发人员使用的是 Windows 和 git bash(他最初尝试使用 GUI,但由于遇到问题,我们决定暂时坚持使用命令行 git 以调试错误)。
  • 开发人员在他的 Windows 机器上的用户名是“raimo”,但我在服务器中创建了他的帐户,其 git 存储库为“ramon”。

无论如何:他可以毫无问题地将 git 存储库克隆到他的本地计算机,但是当他尝试推送更改时,他得到一个错误:“致命:协议错误:错误的行长度字符:ramo”

我们看到this question的答案,所以我告诉他这样做:

ssh ramon@[server.name] git-receive-pack /var/git/[repository name]

他得到的回应是:

008c61c2ff5944d78bf10df33731c40cf972a0e4bfb2 refs/heads/[branch name 1] report-status delete-refs side-band-64k ofs-delta
004c9c518491c3f863b2830dcb4d0dbe9cd7919ba50b refs/heads/[branch name 2]
004eb7909056d60b8188e8e41d6b614c8e88e2cf848b refs/heads/[branch name 3]
004c3ef6b4c43034157dcce61e2a98c84ad7e7c695c9 refs/heads/[branch name]
004d4d423c5dc669f7d827b63d9c29c11b569281f391 refs/heads/[branch name]
004f6cfbabad11009a2c451ad8cf9e1837b417394e7e refs/heads/[branch name]
00494c96774aad57f200fe61e56d12fd5c69f6154139 refs/heads/[branch name]
004777ef2fc618ccacad372cd720f95591d4a347fc92 refs/heads/call_to_action
00490bad8d61d3213c1ece42a4e0f432e053ce9eeef9 refs/heads/[branch name]
004061ae4b7acec207773adff985bc6cf504a107aadc refs/heads/carrito
0052ca13ffe125f3b96b7176654e6ac5a472525c4019 refs/heads/[branch name]
004fe341b335ca9bd57d9e1bd0a69d75879292313a8c refs/heads/[branch name]
004288b199d02b21a26b5e3ce25c204b49b80ef63ac5 refs/heads/etiquetas
003d4cb828f02d61054e0320dead63c7f285ca84dfc3 refs/heads/help
004ba9baf7fd376ddc2017222fe07fa2a4c496e129fd refs/heads/[branch name]
005991a2b4b742e2f1793e71d85a0565aec4fa65b415 refs/heads/[branch name]
0048f6545418765d79a3c07

这对我来说看起来不错(或者至少看起来像是 git 协议)。

然后我们尝试在机器中设置他的公钥。他给我发了他的公钥,看起来像:

ssh-rsa [key blablablabla] raimo@DESKTOP

我将它添加到他在 git 框的用户帐户中的 authorized_keys 文件中,但发生了完全相同的事情。他无法使用 git 推送,而我在服务器日志中得到的错误是:

sshd[14411]: Failed publickey for ramon from [ip address]

一直以来,他都可以毫无问题地使用 PuTTY SSH 进入服务器。 (现在想起来,我并没有要求他在 git bash 中使用命令行 SSH 客户端进行 SSH;将报告结果)。

发生了什么事?

【问题讨论】:

    标签: git ssh openssh


    【解决方案1】:

    首先,在远程服务器上检查 ~ramon 的 .profile/.bashrc 是否有任何类型的回显,显示任何内容。如果是这样,那可能会干扰一些 git 命令,例如 clone。


    本地,检查他的环境变量GIT_SSH的值

    如果是TortoisePlink.exe:

    • 尝试将其设置为 ssh.exe as in here
    • 使用 putty 将 ppk 密钥转换为 id_rsa/id_rsa.pub 私钥/公钥

    OP PaulJ 确认 in the comments 这是一个 SSH 密钥问题

    最后,问题只是他没有正确配置他的公钥/私钥对。

    【讨论】:

    • 你好。感谢您的回答;我们检查了 .bashrc 并没有什么特别之处。最后发现问题只是他没有正确配置他的公钥/私钥对。
    • @PaulJ 太棒了!我已将您的评论包含在答案中以提高知名度。
    猜你喜欢
    • 2010-10-25
    • 1970-01-01
    • 2021-06-07
    • 2013-01-27
    • 2018-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多