在Windows 7上代理后面的git中的SSH

Son*_*nd 26 windows ssh proxy

我正在测试SSH连接以检查git中的RSA密钥.我正在代理服务器上工作.我正在使用Windows 7并安装了msysGit-fullinstall-1.7.3.1-preview20101002.现在在msys.exe窗口中,我已经通过命令'git config --global http.proxy http:// host:port ' 设置了代理.之后我尝试了命令'ssh git@github.com'.这给了我像'ssh:github.com这样的错误:没有与name相关的地址'

我该怎么办?

wim*_*ica 47

设置http.proxy不适用于ssh.您需要代理您的ssh连接.请参阅说明.总结一下:

开始git-cmd.bat并创建~/.ssh/config(notepad %home%\.ssh\config.)

ProxyCommand /bin/connect.exe -H proxy.server.name:3128 %h %p

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\users\username\.ssh\id_rsa"
  TCPKeepAlive yes
  IdentitiesOnly yes

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\users\username\.ssh\id_rsa"
  TCPKeepAlive yes
  IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)

(设置正确的代理主机名:端口,以及id_rsa的路径.当你使用git-bash时,在id_rsa的路径中使用斜杠)
(我的msysgit版本包括connect.exe,所以我不需要下载和编译connect.c) .这里也提供预编译的exe .

现在ssh github.com应该工作

请注意,如果要通过socks5代理连接,请更改-H-S.

ProxyCommand connect -S proxy.server.name:1080 %h %p
Run Code Online (Sandbox Code Playgroud)

如果使用Linux文件系统,则文件权限~/.ssh/config必须为600,但在标准NTFS Windows分区上,这些权限不存在.

如果您的代理需要NTLM身份验证,则可以使用cntlm,另请参阅此答案.

  • 在我的系统上,connect.exe 安装在不同的位置。为了让它工作,我必须设置 ProxyCommand "/c/Program Files/Git/mingw64/bin/connect.exe" -S proxy.server.name:1234 %h %p(注意我使用的是 SOCKS5 而不是 http 所以我将 H 更改为 S) (2认同)
  • 谢谢@wimh。我还在Windows计算机上的** C:\ Program Files \ Git \ mingw64 \ bin \ connect.exe **中找到了它,并安装了适用于Windows 64位的Git。 (2认同)
  • 使用最新的官方 Windows Git 版本,我不得不使用 `ProxyCommand connect.exe -H proxy.server.name:3128 %h %p`(`connect.exe` 捆绑在 git 的 `mingw64\bin` 目录中,该目录似乎是在运行 `git` 命令时添加到路径中) (2认同)

Ian*_*han -2

您的代理需要密码吗?那么可能就是这样了。

export http_proxy="http://<domain>\<username>:<password>@<server>:<port>"

请参阅:如何通过 HTTP 代理从 Git 存储库中提取内容?(复制!)