Github behind a proxy

Suppose you have an account to github and you want to use it even when you are behind a very restrictive proxy.
The problem arises “only” when you have to push new patches, given that you can clone/pull even using http out of the box.

Luckily the github guys give us the access to another server (ssh.github.com) which basically listen on the port 443 and forwards

The informations to set up your environment can be found here:

github over proxy

And here you find:
corkscrew

This for example is my configuration (on Macosx but on linux is the same):

SSH_CONFIG

Host gitproxy
  User git
  HostName ssh.github.com
  Port 443
  ProxyCommand corkscrew <proxy> <port> %h %p
  IdentityFile /Users/andrea/.ssh/github

Now in your git repository you can simply add the new remote

git remote add git@gitproxy:<repository>

Another nice way to bypass the proxy (thanks Christian) is to use the GIT_PROXY_COMMAND variable, in this way

export GIT_PROXY_COMMAND=/usr/local/bin/proxy-cmd.sh

#!/bin/bash
(echo "CONNECT $1:$2 HTTP/1.0"; echo; cat ) | socket proxy.unitn.it 3128 | (read a; read a; cat )

And now git for every push/pull will execute that script and bypass the proxy.

Advertisement

One Response to Github behind a proxy

  1. Christian says:

    Actually this one-liner script does exactly the same as corkscrew! So you can also place this line in ~/.ssh/config:

    ProxyCommand /usr/local/bin/proxy-cmd.sh %h %p

    As well, you can replace the long line in the shell script by a call of corkscrew with the proxy information.

    Another note: (at least for my installation), the “git add” command needs another argument . However, i do not yet get “push”ing or “fetch”ing to work, but that may be another problem…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.