Accessing Subversion repository with 2 hops using svn+ssh protocol

sshsvn

My Ubuntu Subversion server is not directly accessible to the Internet, 192.168.1.2

My public Ubuntu machine is exposed through the DMZ at 192.168.1.1

I've setup port forwarding from 192.168.1.1:3906 to 192.168.1.2:3906, but I have no idea how this would work with svn+ssh since one extra hop is required to reach my Subversion server

edit: For anybody going through the same problem, my confusion came because I was trying to port forward to my SVN server (running a daemon at port '3906') but accessing your SVN server through SSH is totally different from accessing your SVN server running a daemon (at 3906). You need to treat this as a typical ssh connection. Both of the methods below worked once I edited my settings

Best Answer

Put something like this in your .ssh/config file:

Host subversionserver
        Host=192.168.1.1
        ProxyCommand = ssh 192.168.1.1 /usr/local/bin/nc -w 60 192.168.1.2 %p
        ForwardX11 = no
        User = myusername
        ForwardAgent = yes

Then you'll be able to connect to your ssh server with just:

ssh subversionserver

Basically you'll log in to your public box and run the netcat command once you get in. Your desired to the subversion server SSH connection will be going over the netcat connection.

Obviously you'll need to have netcat somewhere on your box.

The version in my .ssh/config file has a wildcard Host and uses %h in the netcat command. Very useful when you want to proxy through for all the boxes in a production environment that you have to go through a DMZ to get to.

Related Topic