I was tasked to help a customer move their subversion server to the “cloud” (azure in this instance).
Due to various factors, we chose not to use a VPN but rather go with svn+ssh to connect to the remote subversion repository.
Anyway, this post is to describe how to configure TortoiseSVN to connect to the svn+ssh remote server.
Firstly, the software I used:
- TortoiseSVN - https://tortoisesvn.net/downloads.html. I’m using version 1.9.4
- Putty - http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. I used the msi installer for version 0.67.
- Windows 8 and 10. In theory this should work on Windows 7 with some modification.
I’m assuming you are using a keypair to authenticate with the svn+ssh service.
I’m also assuming that you have created a keypair that Putty can use. Follow the instructions at https://the.earth.li/~sgtatham/putty/0.67/htmldoc/Chapter8.html#pubkey-puttygen. If your keypair was generated using openssh, then you’ll need to convert it to a format that Putty can use. Puttygen can be used to do that, although it doesn’t support the newer format from openssh.
Lastly, I’m assuming your keypair uses a passphrase. If not, you definitely should be.
We need to configure a new Saved Session in Putty that we will refer to later in TortoiseSVN. This will tell TortoiseSVN the connection details and private key to use when connecting to the svn+ssh service.
Launch Putty.exe. If you used the msi installer, it should be on your desktop. You’ll the standard Putty dialog show:
We need to tell Putty where to find our Private Key on disk. So in the left-hand panel drill down to Connection->SSH->Auth and you’ll see this:
Enter in the path to your Private Key:
Now we need to tell Putty our Host connection details. So (1) go to the Session option. (2) enter in your Host and Port connection details; (3) Enter in a and in the text box below “Saved Sessions” label, (2) enter in a descriptive label then (3) click “Save” button. You’ll see that label show up in the list box below the text box. This has saved the details you entered into a named config so we can refer to it in TortoiseSVN.
Finally, we must save these details as a Saved Session. In the text box below “Saved Sessions”, (1) enter in a descriptive label. I strongly recommend not using any spaces. It makes a big difference later on.
Now (2) click on the “Save” button to save the details as that label.
You can close Putty now (click the Cancel button).
We need to quickly configure TortoiseSVN to know how to connect to an svn+ssh connection.
Open up your TortoiseSVN settings dialogs (you can find it in your Programs menu or by right-clicking in Windows Explorer and selecting TortoiseSVN -> Settings).
Navigate to Network in the left-hand panel. In the “SSH client:” text box enter in the path to the TortoisePlink.exe utility. If you installed TortoiseSVN with the defaults, the path should be
Test the Connection
We can now attempt to connect to the remote subversion repository.
Open up the TortoiseSVN Repository Explorer and type in the url to the remote Subversion repository. The svns+ssh url is as follows:
username: The name given to you by the Subversion administator.
putty_session_name: The name we used in the Save Sessions text box in Step 4 in section “Configure Putty”. E.g. “examplesvn”
repostitory_name: The name of the repository you’re connecting to.
So for example, if Bob wanted to connect to the research repository, the url would be:
Note: If this is the first time you are attempting to connect to the remote Subversion repository, you will prompted on whether you trust the server you are connecting to and want to cache the server’s key.
You will then be prompted for your Private Key passphrase:
And then re-prompt several more times. After which if everything was correct you’ll see your repository in the Repository Browser.
The reason why were you prompted several times for your passphrase is due to how svn protocol works whereby it makes multiple seperate connections to the server. And each connection requires a re-authentication. This will get very annoying after a short time.
To reduce the pain, we’ll use a utility called Pageant that will cache your decoded Private Key in memory after the first time you enter in your passphrase.
Setting up Pageant
The way Pageant works is that the first time it runs, it prompts you for your Private Key passphrase and then whenever Putty needs to use that Private Key, it uses the already decoded Private Key information to do the ssh handshake.
The easiest way of doing this, is running Pageant on Windows startup.
Open up the Task Scheduler (otherwise known as Scheduled Tasks).
Create a Basic Task by clicking on the “Create Basic Task…” in the Actions panel:
Enter in a name for the task then click “Next >”.
Select “When I log on” option for when you want the task to start. Then click “Next >”.
Select “Start a program” for the action. Then click “Next >”.
For the “Program/script:” value, enter in
c:\Program Files (x86)\PuTTY\pageant.exeassuming you used the MSI installer for Putty. You also need to add the path to your private key into the “Add arguments” text box. Make sure you surround the path in double-quotes (just in case the path has spaces). So something like this:
Click Next >.
If you’re happy with what you entered in, Click “Finish”.
Now you definitely want to test this out, so log out of Windows then log back in. When you log in, you should see the following prompt from Pageant:
If the passphrase is correct, the dialog will just disappear.
From now on, when you connect to the remote Subversion repository, you will no longer be prompted for any passphase.