【问题标题】:git clone failed to begin relaying via HTTPgit clone 无法通过 HTTP 开始中继
【发布时间】:2018-10-29 19:34:19
【问题描述】:

当使用 git clone 时,我遇到了一个错误。 这是命令和错误信息。

[user@linux]$ git clone git@github.com:username/repertory.git
FATAL: failed to begin relaying via HTTP.
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

除了 git@github,git clone https://...... 和 git clone git://...... 都很好用。所以我猜ssh协议有问题,然后我检查了ssh。

[user@linux]$ ssh -T git@github.com
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

看来我可以通过ssh协议正常连接到github了。但是通过 ssh 进行 git clone 有什么问题呢?

【问题讨论】:

  • 您似乎在.gitconfig 中使用代理配置。请发布相关配置(您可以省略任何密码)。

标签: linux github ssh


【解决方案1】:

此错误消息来自connect.c from SSH

这是一个SSH Proxy Command -- connect.c,通过 SOCKS 和 https 代理建立网络连接的简单中继命令:您可以使用此命令在防火墙之外建立 SSH 会话。

因此,请检查是否需要这样的连接:如果您在防火墙后面的企业中,很可能需要它,但在这种情况下,请联系您的 IT 支持团队以检查此类解决方案的有效性/批准情况。

并且该错误消息表明即使是这种 SSH 模式(通过 https 代理中继)也可能被阻止。

如果您不在企业环境中,并且不需要代理,请从您的环境变量和您的 git config 文件中删除它们 (HTTPS(S)/PROXY)。

【讨论】:

    【解决方案2】:

    如果您使用代理,许多公司防火墙会阻止对 443 以外端口上的 CONNECT 方法的访问。GitHub 使用主机“ssh.github.com”运行 SSH 服务器侦听端口 443。

    首先,使用以下内容配置您的 SSH ~/.ssh/config

    Host github.com, ssh.github.com
        User git
        Hostname ssh.github.com
        Port 443
        ProxyCommand socat - PROXY:localhost:%h:%p,proxyport=3128
    

    在上面的示例中,我假设您在主机 localhost 和端口 3128(例如 cntlm)上运行 Web 代理。

    您也可以将socat 替换为ncconnect-proxy,语法略有不同。

    测试:

    ssh -T git@ssh.github.com
    Hi username! You've successfully authenticated, but GitHub does not provide shell access.
    

    然后用:

    git clone git@ssh.github.com:username/repository.git
    

    【讨论】:

      猜你喜欢
      • 2013-01-19
      • 1970-01-01
      • 2013-03-10
      • 2021-02-07
      • 2020-01-10
      • 2011-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多