SSH in git behind proxy on windows 7

2019-01-21 14:20发布

I am testing SSH connection for checking RSA key in git. I am working over proxy server. I am using window 7 and have installed msysGit-fullinstall-1.7.3.1-preview20101002. Now in msys.exe window i have set proxy by command 'git config --global http.proxy http://host:port' After that i have tried command 'ssh git@github.com' . This gives me error like 'ssh: github.com: no address associated with name'

What should i do?

2条回答
男人必须洒脱
2楼-- · 2019-01-21 14:36

Setting http.proxy will not work for ssh. You need to proxy your ssh connection. See this description. To summarize:

Start git-cmd.bat and create ~/.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

(set the correct proxy hostname:port, and the path to id_rsa. When you use git-bash, use slashes in the path to id_rsa)
(My version of msysgit includes connect.exe, so I do not need to download and compile connect.c). A precompiled exe is also available here.

Now ssh github.com should work

Note that if you want to connect via a socks5 proxy, then change -H to -S.

ProxyCommand connect -S proxy.server.name:1080 %h %p

If you use a Linux file system, the file permission of ~/.ssh/config must be 600, but on a standard NTFS windows partition, these kind of permissions do not exist.

If your proxy requires NTLM authentication, you can use cntlm, see also this answer.

查看更多
ら.Afraid
3楼-- · 2019-01-21 14:54

Does your proxy require a password? Then it might be that.

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

See : How do I pull from a Git repository through an HTTP proxy? (duplicate!)

查看更多
登录 后发表回答