Subversion + Alternate SSH Ports

September 8th, 2006

One of my clients has a firewall in front of his subversion server, which is accessed within the network with the svn+ssh method. However, outside of the network it’s a different story: the tunnel through the firewall puts the public SSH interface on a non-standard port … and svn+ssh doesn’t play well with non-standard ports.

What’s the work around? A one line tweak in your personal Subversion configuration file. I can only vouch for this on OS X, so your mileage may vary.

  1. Load ~/.subversion/config into your favorite text editor.
  2. Add one line to the [tunnels] section: altssh = /usr/bin/ssh -p alt_port

Then your access method to svn+altssh and you’re ready to rock:

svn checkout svn+altssh://me@host.com/path/to/repo

This raises an interesting question: what other non-standard methods are people using to access their repositories?

Update:  Arlo Bendiken has a better solution to this particular problem in his comment below … put the alternate port into the SSH config, so that any SSH interaction with the host receives the correct settings.  Thanks!

Tagged

3 Responses to “Subversion + Alternate SSH Ports”

  1. September 8th, 2006
    By Arto Bendiken

    I believe you can accomplish this in an easier way by editing your .ssh/config file, instead, and adding a stanza like the following:

    Host ssh.hostname.com
    Port 1234

    This has the benefit that you don’t need to explicitly specify the port when SSHing into the server, either, and of course, Subversion’s standard svn+ssh access method should also honor this setting.

  2. December 29th, 2006
    By Alf Watt

    Peat, your solution is still quite helpful for situations where a local port is forwarded to a remote host beind the firewall you want to traverse.

    My office setup requires that I forward a local port to the remote host and perform my svn+ssh checkout to localhost:2222. The tunnel is the equivelant of:

    ssh -L 2222:precious.example.com:22 user@bastion.example.com

    Of course the port number doesn’t work in the svn checkout URL (why has nobody fixed this…) so I add:

    [tunnels]
    sshtunnel = /usr/bin/ssh -p 2222

    and I can now checkout using my ssh tunnel:

    svn co svn+sshtunnel://locahost/path/to/code/you/want

    Making me one productive worker…

    Best,
    Alf

  3. September 23rd, 2007
    By Paul

    Can confirm that the addition to ~/.subversion/config works fine on Debian as well. Thanks,
    Paul.

Leave a Reply