Using svn+ssh On Windows

Subversion supports repository access over an SSH tunnel. That is good news because the first "S" in SSH stands for secure. So the next question is how do we configure Subversion to use SSH?

Unix users are usually familiar with SSH; it has supplanted telnetd as the de facto shell daemon. For this reason we will not cover svn+ssh on Unix here - there are existing resources for that. This article will explain exactly how to svn+ssh on Windows.

The things we need to know going into this are:

  • Repository URL
  • Username
  • Password, or,
  • Public/Private key

A brief note on password vs. key authentication. If there is a choice, use key authentication. It is much more secure and frankly less hassle once setup. Key authentication can occur non-interactively making it a great option for scripted access of a repository.

Convinced? Well then I will assume key authentication going forward. If you are using password authentication then simply omit any of those steps. You will have been provided a public/private key pair. In this article we use plink for SSH. Unfortunately it uses a custom key format - so the first thing to do us convert your key:

  • Download and run PuTTYGen
  • Choose Load
  • Select your key file
  • Choose Save private key

The next thing is to test SSH access - without using Subversion. Open a command window and execute:

plink -i <key filepath> -l <username> <hostname> echo hello
Answer yes to any prompts and the server will respond with Hello.

The next thing is to configure the SSH scheme in Subversion. Open a text editor and load %APPDATA%\Subversion\config. Find the [Tunnels] section and set the SSH scheme as follows:

ssh=plink -i <key filepath> -l <username>
Be absolutely sure to use forward slashes (/) in the path - otherwise the scheme will not work. Also, spaces in the path must be escaped with back slashes (\).

Now you are ready to access your repository over SSH - without password interaction. Open a command prompt and execute:

svn info svn+ssh://hostname/path/to/repo

That is all it takes...but sadly even this small amount of information is not well documented on the Web. Hopefully this saves one person a couple hours of head-scratching.

TortoiseSVN

Follow these steps to get TortoiseSVN working over an SSH channel:

  • Open TortoiseSVN Settings
  • Choose Network section
  • Enter path and parameters to TortoisePlink: C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe -i \path\to\keyfile -l username

Comments

Thank you

Thanks Rjae, Great Info!

Great - and working :-)

I have tried to follow about five other documentations / instructions to get svn+ssh running from the windows command-line. All the others didn't work for me, this one does!