Menu

Using SSH Keys with SVN on Windows

Configuring TortoiseSVN for svn+ssh

Simply use the svn+ssh URL for access. eg., svn+ssh://username@svn.code.sf.net/p/projectname/svn/

TortoiseSVN doesn't need any extra configuration to use svn+ssh, however as it doesn't save your password, it will continue to prompt for the user password whenever needed, which may be multiple times for a single checkout or commmit. To get around this, we recommend using pageant with an SSH key

Using an SSH key with TortoiseSVN

  1. Download Pageant and PuTTYgen
  2. Follow these instructions for generating an SSH Key, using USERNAME@svn.code.sf.net as the key comment. Make sure to save the private key data.
  3. Post the public key to your Account SSH page
  4. Start pageant.exe and add the private key
  5. Use TortoiseSVN as normal, you should no longer be prompted for a password.

So you don't have to repeat step 4 every time you start your computer, you may want to configure pageant to startup automatically with Windows

This guide may also be useful.


Configuring a command line svn client

While ssh is generally available "out of the box" for *nix systems, this is not true for Windows, this guide is to help you get that set up.

And of course, to give credit where credit is due. I'm generally taking the steps from this svn+ssh guide, and just pointing out the SourceForge specific steps.

Generating and setting up ssh keys

  1. Download Plink and PuTTYgen
  2. Follow these instructions for generating an SSH key, using USERNAME@svn.code.sf.net as the key comment. Make sure to save the private key data.
  3. Post the public key to your Account SSH page
  4. Test if this works and store the SF repo host key*, e.g. using username "sillygoose":
C:\SourceForge\ssh>plink.exe -i sillygoose-svn.ppk sillygoose@svn.code.sf.net
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 86:7b:1b:12:85:35:8a:b7:98:b6:d2:97:5e:96:58:1d
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n) y
Using username "sillygoose".
Last login: Wed Aug 15 13:27:53 2012 from <snip>

Welcome to *.svntest.sourceforge.net

This is a restricted Shell Account
You cannot execute anything here.

C:\SourceForge\ssh>

*aside from just testing the key, this step is important for storing the host key. If you wait until step <x> below, it won't work</x>

Configuring svn to use the ssh key

Now you need to configure Subversion to use plink for “svn+ssh” uri.

  1. Edit the file c:\Documents and Settings\user\Application Data\Subversion\config (replacing "user" with your Windows username)
  2. Locate the section named [tunnels]
  3. Add the following line:
ssh=c:/path/to/plink.exe -i c:/path/to/your/key.ppk

Now you can connect via svn+ssh:

svn co svn+ssh://user@server/path/to/svn/repository

Related

Documentation: TortoiseSVN

MongoDB Logo MongoDB