【问题标题】:How to Setup Corkscrew to Connect to Github through Draconian Proxy如何设置 Corkscrew 以通过 Draconian 代理连接到 Github
【发布时间】:2014-01-24 06:39:46
【问题描述】:

我的公司有一个严格的代理服务器,它阻止我通过 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

任何人都知道我做错了什么以及如何让它发挥作用?谢谢。

【问题讨论】:

    标签: git ssh proxy


    【解决方案1】:

    我终于明白了。我公司的代理服务器阻止了除80和443以外的所有端口的通信,所以我无法连接到github上的22端口。我以为我在网上找到的示例是将通信从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了。

    【讨论】:

      猜你喜欢
      • 2015-08-20
      • 2011-07-24
      • 2016-07-19
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-04
      相关资源
      最近更新 更多