Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH in git behind proxy on windows 7

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 [email protected]' . This gives me error like 'ssh: github.com: no address associated with name'

What should i do?

like image 552
Soni Anand Avatar asked Feb 24 '11 10:02

Soni Anand


People also ask

Can you SSH through a proxy?

You need an SSH client that can issue CONNECT requests through the company HTTP proxy. If you're on Windows, using Putty is fine as it has built-in support for tunneling through a HTTP proxy. If you're on unix/linux (or cywgin) you can use openssh with corkscrew to go through the proxy to your home computer's port 443.

How do I Git behind a proxy?

Setting the proxy for Git Run the following commands replacing USERNAME , PASSWORD , PROXY_ADDRESS , and PROXY_PORT with your network's information: git config --global --add http. proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT. git config --global --add https.


1 Answers

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.

like image 196
wimh Avatar answered Oct 07 '22 17:10

wimh