Saturday, September 28, 2013

Bypassing (Great) firewall to access GitHub / BitBucket via SSH Tunnel

Sometimes, you may be blocked by a firewall and cannot access GitHub / BitBucket. In this post, the steps to bypass the firewall using SSH tunnel is documented.

Step 1 - Setup the tunnel

Assuming you use SSH to perform git operations (git clone, fetch, pull, merge, etc.), you should find a SSH URL like: or In order to access the blocked SSH hosts, we have to SSH tunnel to forward the requests. To do so, use the following commands to create a tunnel (assume you have a SSH host that can be accessed).

ssh -C -L  # Establish a tunnel to, SSH requests to local port 8022 are forwarded to

ssh -C -L  # Establish a tunnel to, SSH requests to local port 8122 are forwarded to

Of course, you can combine the two to have one SSH session only.

ssh -C -L -L

Step 2 - Config SSH client

After you have your tunnels, you can then configure your SSH client to redirect SSH requests to your tunnels. Put the following lines in your ~/.ssh/config file.

Port 8022

Port 8122

Afterwards, feel free to use git clone or git clone (you can also use git fetch, pull, merge, etc.). All requests will be passing through your SSH tunnel.
© 2009 Emptiness Blogging. All Rights Reserved | Powered by Blogger
Design by psdvibe | Bloggerized By LawnyDesignz