Subversion + Alternate SSH Ports

September 8, 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://

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!


7 Responses to “Subversion + Alternate SSH Ports”

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

    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. Alf Watt Says:

    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

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

    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…


    • Sari Says:

      Thanks, this works for me too.

      edit .subversion/config and add:
      sshtunnel = /usr/bin/ssh -p 2222

      edit .bashrc and add:
      alias startsvntunnel=’ssh -f -L 2222: user@remotesvnserver’

      then in bash:
      svn co svn+sshtunnel://user@localhost/path/to/svnrepo

  3. Paul Says:

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

  4. Luke Says:

    Thanks so much for this post! It was a lifesaver!

  5. Ryan Says:

    Thank you! 😀

  6. Hari Says:

    Thanks a lot, I am in the same boat as Alf Watt and your post helped.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: