Sunday, November 16, 2008

Why I love GIT and GITHUB..:)

.......is I can push my changes to public repo, sitting behind one of those corporate network, which allows only http/https through them...

On GITHUB we can host our repos and access from anywhere..( from behind corporate firewalls, proxy...)

There are many links out there over internet, which helps us how to do that...but the basic thing what I was doing wrong was trying to push on ssh's default port 22 and to server github.com, rather than ssh.github.com.

Finally reading this end, I was successful in git-push!. Here is how we can do that....

Variables to be set before proceeding.

++ For those who are lucky ( got root / sudo access ) ++

1. Install corkscrew...( apt-get upgrade corkscrew)
2. edit ~/.ssh/config

Host 65.74.177.142
ProxyCommand corkscrew 8080 %h %p ~/.ssh/proxyauth
Port 443
ServerAliveInterval 10
IdentityFile /home/dilipm/.ssh/github

Where,
- 65.74.177.142 is the IP of ssh.github.com. found from nslookup
- File ~/.ssh/proxyauth contains your username and passwd of proxy server. in format username:passwd

- 443, this is where I was doing wrong! I was trying port 22.
- /home/dilipm/.ssh/github, path of my private key

3. set env variable GIT_PROXY_COMMAND=/home/dilipm/.ssh/proxy_cmd_for_github.
where cat /home/dilipm/.ssh/proxy_cmd_for_github is,
corkscrew 8080 65.74.177.142 443 ~/.ssh/proxyauth


That's it...now just do ssh -v git@ 65.74.177.142
At the first attempt the server's (ssh.github.com) fingerprint will be added to local know_hosts file.

++ For those who are unlucky ( don't have root access ) ++

1. download the perl script of Mark suter..
ssh-https-tunnel

2. change the proxy details as required...

3. change the ProxyCommand in ~/.ssh/config as below,
ProxyCommand ~/ssh-https-tunnel.pl %h %p

that's it....try doing ssh -v git@65.74.177.142