Using TortoiseSVN with svn+ssh tunnel over non-standard ports

Configuring recent versions of toirtoise SVN to work with non-standard ports is a bit tricky. I tried editing the “subversion config file” through Settings->General->Edit, to using an ssh command line, like the one I’m using on Linux for the same repository, but that didn’t work.

A quick hack-style solution is to go to TortoiseSVN->Settings->Network and set the SSH client to (assuming port number XX): “C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe -P XX” (The hack is also described here: http://www.supernifty.com.au/blog/2007/09/27/hack-it-1-change-the-tortoisesvn-ssh-port/ )

The issue with this hack is that if you have multiple repositories, each with different ports, this does not work. A more generic and elegant solultion is to use a batch script that is able to parse correctly an SVN URL of the type svn+ssh://[email protected]:port/svn/dir with the correct port, and use it as a wrapper of your TortoiseSVN ssh agent.

You can find a working script with this solution here: http://unformatt.com/news/non-standard-ssh-ports-with-tortoise-svn/

I’m quoting the batch script here (for redundancy purposes):

@echo off
set HOST=%1
set PORT=%HOST:*:=%




IF [%PORT%]==[%HOST%] (
 set PORT=22
 )
 c:\\Progra~1\\TortoiseSVN\\bin\\TortoisePlink.exe -P %PORT% %HOST% %2 %3