Tomorrow is Friday

November 28, 2007

Tunneling Subversion for the svn+ssh protocol

Filed under: svn — dirkn @ 10:29 pm

If you use the svn+ssh protocol to check out files on your laptop while at work (inside a trusted network) and later on you want to access the same repository from a remote site, then it might be that you are forced to first tunnel through a firewall. In that case the normal port number mambo jambo on the svn URL’s doesn’t work since you are already using ssh to do the tunneling.

A possible solution would be to start a tunnel from your laptop to the svn repository computer through the firewall and to change the repository root to point to localhost. This is a bit clumsy but easy to understand.

  1. First make a tunnel from your laptop to the repository: ssh -L10022:repository:22 -N -t -x username@firewall
  2. Test the tunnel (this makes sure it works and that an entry of localhost:10022 will be added to your ssh known_hosts file such that ssh-agent works like a charm) by doing ssh -p 10022 username@localhost. (Note that the username is always the remote username in these snippets!)
  3. Add a custom protocol to your .subversion/config file. Under the heading [tunnels] add tunnel_ssh = $TUNNEL_SSH ssh -p 10022.
  4. Now switch the root in your repository from svn+ssh://username@repository/path/to/repository to svn+tunnel_ssh://username@localhost/path/to/repository. You can do this by executing the following command from in the checked out root of your repository on your laptop: svn switch --relocate svn+ssh://username@repository/path/to/repository svn+tunnel_ssh://username@localhost/path/to/repository.
  5. Test if it worked. E.g. by doing svn info and svn update.

You can read this information in the svn book as svnserve, a custom server (search for “joessh” on that page).


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: