Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Tuesday, November 26, 2013

Accessing Git Repositories using SSH behind HTTP proxy (TortoiseGit, Putty)

There's an easier way to do this since my previous post on the subject above. SSH key generation steps are not discussed here, but the only thing worth mentioning here is that the private key be in PPK format (use PuTTYgen to convert them)

Using TortoiseGit, use Putty to save a 'Session'. Name the session short and simple e.g. hornetsnest. This is significant and to make things simpler, no spaces for the session names.

Under the saved Putty session, the place to add proxy information is at Connection > Proxy. For HTTP proxy:
  • Proxy hostname - IP or host name of proxy server
  • Port - Proxy server port e.g. 8080
  • Username - User login Id if proxy server requires authentication
  • Password - Login Id password
To associate a SSH key, go to SSH > Auth and specify the PPK key file path under "Private key for authentication".

Remember to save the Putty session.

Now, shift over to TortoiseGit. In the window to specify the Git repository URL, instead of the usual host name value, replace it with the Putty session name. In this example, hornetsnest. So

ssh://workerbee@imperialpalace.ip/~/git/super.git

becomes

ssh://workerbee@hornetsnest/~/git/super.git

So the connection to the Git repository via SSH will use the settings in the Putty's session. Of course, when you are not behind a proxy, you can just revert to the original URL when cloning/pulling/pushing.

Minor update: You'll need to use TortoisePlink as SSH client:


Tuesday, September 18, 2012

Accessing Git Repositories using SSH behind HTTP proxy (Corkscrew, OpenSSH)


OpenShift uses SSH for its Git repositories. But at my workplace, where I need to use a HTTP proxy to access the Internet, getting TortoiseGit to connect to the Git repository seemed impossible. Out of the box, SSH can't be accessed via HTTP proxies. After vigorous searching using Google, I came across Corkscrew (http://www.agroman.net/corkscrew/README). Corkscrew enables tunnelling of TCP connections through HTTP/S proxy servers.

Since I am using Windows, and happen to use Cygwin (was required by OpenShift) and TortoiseGit, here's what I did to make it work:
1. Fire up Cygwin setup, searched for 'corkscrew', download packages
2. In my Cygwin home folder (default folder for SSH settings), open file ~\.ssh\config
3. Add/modify the ProxyCommand line (replace with your proxy IP and port) as shown in the example below:

Host *.rhcloud.com
  IdentityFile ~/.ssh/libra_id_rsa
  VerifyHostKeyDNS yes
  StrictHostKeyChecking no
  UserKnownHostsFile ~/.ssh/libra_known_hosts
  ProxyCommand /bin/corkscrew localhost 8118 %h %p

4. Open TortoiseGit's Settings window, go to Network. Check the 'Enable Proxy Server' option, and add the proxy IP and port values.
5. In the SSH client textbox, enter the path to the ssh.exe file e.g. C:\cygwin\bin\ssh.exe. This assumes that you are using OpenSSH in Cygwin. Click OK.

That's it, now you can access your Git repository via SSH behind a HTTP proxy!