如何通过苛刻的代理使用GitHub?

Gre*_*con 23 git github

鉴于以下限制,我如何使用Windows和Unix中的GitHub?

  • 所有访问互联网仅限于代理
  • 代理仅允许在端口80和443上连接
  • CONNECT方法仅对443启用
  • 需要代理身份验证(NTLM或Basic)

Gre*_*con 22

请参阅Jeff Tchang 的"使用Github通过Draconian Proxies(Windows和Unix)"(以前可从其他位置获得),其中包括Windows和Unix平台的说明,总结如下.

Unix的

  1. 下载Git.
  2. 下载并安装开瓶器.
  3. 编辑或创建文件~/.ssh/config并输入以下内容:

    ProxyCommand /usr/bin/corkscrew proxy.example.com 443 %h %p ~/.ssh/myauth
    
    Host github.com
    User git
    Port 22
    Hostname github.com
    IdentityFile "/media/truecrypt1/Keys/GitHubKey.private"
    TCPKeepAlive yes
    IdentitiesOnly yes
    
    Host ssh.github.com
    User git
    Port 443
    Hostname ssh.github.com
    IdentityFile "/media/truecrypt1/Keys/GitHubKey.private"
    TCPKeepAlive yes
    IdentitiesOnly yes
    
    Run Code Online (Sandbox Code Playgroud)
  4. 如果一切设置正确,您应该能够运行ssh github.com并查看

    嗨用户!您已成功通过身份验证,但GitHub不提供shell访问权限.
    与github.com的连接已关闭.

    如果这不起作用,你可以运行ssh ssh.github.com并得到完全相同的东西.如果第一个命令不起作用,则意味着您正在使用阻止端口22上的CONNECT的代理.几乎没有代理阻止端口443上的CONNECT,因为您需要SSL.

视窗

  1. 下载msysgit.一些设置:
    • "从Windows命令提示符运行Git"
    • "使用OpenSSH"(这个非常重要)
    • 选择你的行尾
  2. 下载connect.c.这个工具值得拥有自己的帖子,主要是因为它非常简单.它反映了开源工具开瓶器,用于通过代理进行隧道传输.是的,工具的名称实际上称为"connect.c".对于Windows用户,可以使用预编译的二进制文件.我把我connect.exeC:\Windows\connect.exe.
  3. 决定你是否喜欢使用Windows cmd.exe来做东西或者使用Cygwin风格的shell.或两者.
  4. 设置Cygwin Git bash shell.

    对于Cygwin样式shell,启动Git图标并编辑文件~/.ssh/config,并确保文件没有扩展名.将以下内容放在该文件中,并注意如何指定路径.

    ProxyCommand /c/windows/connect.exe -H username@proxy.example.com:443 %h %p
    
    Host github.com
    User git
    Port 22
    Hostname github.com
    IdentityFile "/c/Keys/GitHubKey.private"
    TCPKeepAlive yes
    IdentitiesOnly yes
    
    Host ssh.github.com
    User git
    Port 443
    Hostname ssh.github.com
    IdentityFile "/c/Keys/GitHubKey.private"
    TCPKeepAlive yes
    IdentitiesOnly yes
    
    Run Code Online (Sandbox Code Playgroud)
  5. 设置Windows cmd.exeshell.

    假设您不喜欢Git Bash shell.您更喜欢cmd.exe解释器.

    • 转到您的配置文件 C:\Documents and Settings\.ssh\config
    • 复制它或制作一个新的.我打电话给我config-windows

    将以下内容放在文件中,再次注意路径分隔符和样式.

    ProxyCommand C:/Windows/connect.exe -H username@proxy.example.com:443 %h %p
    
    Host github.com
    User git
    Port 22
    Hostname github.com
    IdentityFile "C:\Keys\GitHubKey.private"
    TCPKeepAlive yes
    IdentitiesOnly yes
    
    Host ssh.github.com
    User git
    Port 443
    Hostname ssh.github.com
    IdentityFile "C:\Keys\GitHubKey.private"
    TCPKeepAlive yes
    IdentitiesOnly yes
    
    Run Code Online (Sandbox Code Playgroud)

有关完整详细信息,请参阅完整的博客文章.

  • `connect.exe`是作为msysgit的一部分安装的.它包含在[2010年2月](https://github.com/msysgit/msysgit/commit/7b1870d634e7672abbbd2f528cb66fc2c4b8a431)中. (3认同)
  • 我想补充一点,对于NTLM身份验证,您可以使用CNTLM.大多数企业代理允许基本身份验证,但有些真正限制,只允许NTLM. (2认同)