Git over an ssh tunnel (like through a firewall or VPN) | RandyFay.com

Git over an ssh tunnel (like through a firewall or VPN) | RandyFay.com

Submitted by rfay on Mon, 2010-10-11 18:41gitsshIt’s a treasured geek secret that ssh can tunnel TCP connections like ssh all over the internet. What does that mean? It means that you can access machines and ports from your local machine that you never thought you could, including git repositories that are behind firewalls or inside VPNs.There are two steps to this. First, we have to set up an ssh tunnel. We have 3 machines we’re interacting with here: The local machine where we want to be able to do a git clone or git pull or whatever. I’ll call it localhost. The internet or VPN host that has access to your git repository. Let’s call it proxy.example.com. The host that has the git repository on it. We’ll call it git.example.com, and we’ll assume that access to git is via ssh on port 22, which is very common for git repos with commit access.Step 1: Set up a tunnel (in one window). ssh -L3333:git.example.com:22 you@proxy.example.comThis ssh’s you into proxy.example.com, but in the process sets up a TCP tunnel between your localhost port 3333 through the proxy internet host and to port 22 on git.example.com. (You can use any convenient port; 3333 is just an example.)

via Git over an ssh tunnel (like through a firewall or VPN) | RandyFay.com.