如何设置Corkscrew通过Draconian代理连接Github

6
我的公司使用非常严格的代理服务器,阻止我连接到远程服务器进行SSH操作,因此无法使用Github。我在过去的一天里尝试了网上的一些示例,如下所示: 但是似乎没有一个方法有效。这是我的~/.ssh/config文件内容:
ProxyCommand /usr/local/bin/corkscrew proxy02.COMPANY_NAME.com 8080 %h %p

Host github.com
User git
Port 22
Hostname github.com
IdentityFile "/Users/msnider/.ssh/id_rsa"
IdentitiesOnly yes
TCPKeepAlive yes

Host ssh.github.com
User git
Port 443
Hostname ssh.github.com
IdentityFile "/Users/msnider/.ssh/id_rsa"
IdentitiesOnly yes
TCPKeepAlive yes

当我尝试执行git pull --rebase时,收到的错误消息如下:

Proxy could not open connnection to github.com:  Forbidden
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.

当我尝试SSH连接github.com时,出现了相同的禁止错误,但如果我指定我的身份,则可以ssh到ssh.github.com:

ssh -i ~/.ssh/id_rsa git@ssh.github.com
Hi mattsnider! You've successfully authenticated, but GitHub does not provide shell access.
Connection to ssh.github.com closed.

连接代理服务器无需身份验证。

我也尝试设置http_proxyhttps_proxy环境变量:

http_proxy=http://proxy02.COMPANY_NAME.com:8080
https_proxy=http://proxy02.COMPANY_NAME.com:8080

有没有人知道我做错了什么,以及我如何让这个工作起来?谢谢。

1个回答

12

我终于想通了。我的公司代理服务器阻止除80和443端口之外的所有通信,因此我无法在22端口上连接到GitHub。我之前以为网上找到的示例是用于将通信从22端口改为443端口,但实际上并非如此。

问题出在所有网上示例的这段代码:

Host github.com
User git
Port 22
Hostname github.com
IdentityFile "/Users/msnider/.ssh/id_rsa"
IdentitiesOnly yes
TCPKeepAlive yes

这意味着当从代理服务器连接到github.com时,使用主机名github.com和端口22,而我的代理服务器阻止了该端口。通过将github.com的定义更改为:

Host github.com
User git
Port 443
Hostname ssh.github.com
IdentityFile "/Users/msnider/.ssh/id_rsa"
IdentitiesOnly yes
TCPKeepAlive yes

我终于可以连接到GitHub了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接