Github 通过学院代理的 SSH,端口 22 和端口 443 被阻止

Github SSH via institute proxy, port 22 as well as port 443 blocked

有一个 Whosebug 问题@Github (SSH) via public WIFI, port 22 blocked,关于被阻止的 port 22,但是那里给出的解决方案:port 443 对我来说也是失败的。

我所有的互联网连接都通过学院代理服务器,它阻止了所有非标准端口。我知道 port 80port 8080 都是允许的,而且我通过 https 路线进行的所有 github 交易都完美无缺。

如何解决这个问题?

ssh -T -p 443 git@ssh.github.com

ssh: connect to host ssh.github.com port 443: Connection refused

我的代理服务器是:http://10.3.100.207:8080/

您的问题是您的连接没有通过学院代理服务器,根据您的描述,它看起来像一个基本的 HTTP 代理。 Git -- 和 ssh -- 不知道代理。您有多种选择:

  • 使用 https 访问 github,并通过设置 http.proxy 配置选项让 git 知道代理服务器。有这样做的说明 here.

  • 配置 ssh 以使用代理。这将需要像 corkscrew that can forward tcp connections through an http proxy (if the proxy supports the CONNECT method). There is some useful documentation on that topic here.

  • 这样的工具

我找到了解决问题的简单方法。由于 https 非常适合我的设置和代理,我找到了一种方法来强制 git 在遇到 ssh url 时使用 https 而不是 ssh,方法是执行以下 2 git 配置命令:

git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://

这解决了我的问题。

来源:https://github.com/npm/npm/issues/5257