ssh tunnel tunnel through vpn

ssh tunnel tunnel through vpn

I’ve got a headless box at home, which is my endpoint for the office VPN. Being headless, of course, means that to do any work, I have to SSH in from the laptop.

This sucks for doing things on the laptop, my workflow gets studded with ssh calls, and the office jabber server is inaccessible.

So the way around this is to set up a SSH tunnel from the laptop, through the endpoint, to a machine in the office, and use that to connect to the jabber server, and allow direct checkouts from the repository.

In the SSH config ~/.ssh/config:

Host workstation
User jaq
ProxyCommand nohup ssh endpoint nc -w1 %h %p

workstation is my box in the office, that I’m planning on SSHing directly to. endpoint is the box next to me, that I can actually ssh to.

Log into endpoint, and add entries to /etc/hosts for the actual IP of workstation, just in case it can’t look it up.

10.x.x.x workstation

Now, if you ssh workstation from the laptop, it should “just work”; ssh to endpoint and then magically go through the VPN to workstation. (Assuming, of course, that you can ssh from endpoint to workstation – debugging your VPN is out of scope for this post :)

Ok, so that’s working, we can set up an SSH tunnel so that jabber will work:

% ssh -fN -l jaq -L 5222:jabber:5222 workstation

So, as long as workstation can resolve jabber, this will set up a tunnel from port 5222 locally, to port 5222 on jabber.

Edit /etc/hosts on the laptop and add the entry for jabber:

127.0.0.1 jabber

Now, you can connect using gaim to jabber, just as you would if the laptop was in the office, and it’ll magically just work.

To get access to the code repository, just follow the first steps that get you SSHing directly to it (assuming that you use SSH as a transport to the repository).

Now that you appear to be working, time to play some video games.