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.
- First make a tunnel from your laptop to the repository: ssh -L10022:repository:22 -N -t -x username@firewall
- 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!)
- Add a custom protocol to your .subversion/config file. Under the heading [tunnels] add tunnel_ssh = $TUNNEL_SSH ssh -p 10022.
- 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.
- 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