Skip to content

Instantly share code, notes, and snippets.

@harlanbarnes
Last active December 12, 2018 05:21
Show Gist options
  • Save harlanbarnes/fde7790cbcf18216eada to your computer and use it in GitHub Desktop.
Save harlanbarnes/fde7790cbcf18216eada to your computer and use it in GitHub Desktop.
Using SSH ProxyCommand to Bypass Filtering

Overview

If you are in a location that allows SSH but doesn't allow access to GitHub (I'm looking at you India), here's an easy way to get around it.

Prerequisites

  1. You need a shell account on a network that doesn't filter GitHub. Ideas for that:
    1. Pay but Cheap: A micro instance on EC2 http://aws.amazon.com/ec2/pricing/
    2. Free-ish: One of the free shell solutions http://shells.red-pill.eu/
  2. The shell account will need access to the netcat binary called nc http://nc110.sourceforge.net/
  3. The SSH daemon on the shell account will need to allow TCPForwarding (this is usually enabled by default on most sshd systems, but I don't know about those freebie accounts above. I've never used them.
  4. You've setup your key in your SSH agent https://developer.github.com/guides/using-ssh-agent-forwarding/

Setup

This will work for Mac and Linux.

  1. Edit $HOME/.ssh/config

  2. Add an entry such as

Host github.com
  ForwardAgent yes
  ProxyCommand ssh [email protected] nc github.com 22

Where shelluser is your shell username and shellhost.domain.com is the DNS/IP to your non-filtered host.

You can test by running a git command or simply ssh [email protected].

For Windows, have a look at doing the above in Putty using a document like this one: https://monkeyswithbuttons.wordpress.com/2010/10/01/ssh-proxycommand-and-putty/

@ranqiangjun
Copy link

Many thanks, works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment