Using svn over ssh on Windows to access a Subversion repository

First I downloaded and installed a windows binary of subversion, so that I would have the svn client executables.

I went the extra step and set up ssh keys between the widows client and the server so that I could svn without having to enter a password each time.  To so so:

  • Download plink.exe, pageant.exe, and puttygen.exe from the Putty website.
  • Run puttygen.exe to generate a private and public key.
  • After the key has been generated, click on the "Save private key" button towards the bottom of the puttygen dialogue box.  Put it somewhere handy, you’ll need to refer to it later when calling your ssh client.
  • Towards the top of the window is a field that says "Public key for pasting into OpenSSH authorized_keys file:"  Login to your server where your Subversion repository resides.  Append this string to your home/.ssh/authorized_keys file (if it doesn’t yet exist, create it and add the key string).
    • Make sure that you chmod 600 your authorized_keys file so that it is only readable and writeable by the owner of the /home/.ssh directory, otherwise you won’t be able to use it to ssh to your server.
  • Start pageant.exe and load the private key you just generated.
  • Copy a Pageant shortcut to "Startup" under the "All Programs" item on your Start menu.
  • Add the path to your directory that contains plink:
    • Right-click on My Computer and select Properties
    • Click on the Advanced tab and click on Environmental Variables
    • Append the following to the Path System variables:
      • C:\Path\to\plink\dir
    • Restart your machine
  • Test:  From the command line type: plink.exe username@server
  • If it is set up properly you’ll find yourself logged into your serve without a password prompt.
Next, we’ll configure Subversion to use plink for the ssh client.

  • Before you can edit the Subversion config file, you need to fire up a command line terminal and simply type svn.
  • You should get Type ‘svn help’ for usage.  That means Subversion in installed and ready to go.
  • Once you have done that, your configurations file will have been generated in your users Documents and Settings Directory.
  • Edit the Subversion config file for your user.  You should be able to find it under C:\Documents and Settings\username\Application Data\Subversion\config.
    • In some instances the Subversion directory isn’t created in Application Data directory for the user.  In that case, I’ve included a .zip file attached to this article entry.  Simply download the Subversion.zip file, unzip and place the folder in your C:\Documents and Settings\username\Application Data\ folder.
  • Scroll down until you find the [tunnels]section.
  • Add the following:  ssh=plink
  • To add a configuration for the text editor program that you will use to enter notes with each svn commit command, add the following line:  editor-cmd = notepad

That should do it.

Try checking out a copy from your repository.

  • Open up a Command Prompt and type:
  • svn co svn+ssh://user@server/path/to/repository dir_name_for_code
  • That should check out a version of your code from your repository and you should be good to to.

I’m working on a project whereby I need to access an svn Subversion repository over ssh (svn+ssh) on a Windows box.  Following is a step by step of how I got it all working using the svn command line client on Windows XP connecting to a Subversion repository on a linux box running CentOS 5.

Click on “Read More” for the whole article on how to get it all set up.
First I downloaded and installed a windows binary of subversion, so that I would have the svn client executables.

I went the extra step and set up ssh keys between the widows client and the server so that I could svn without having to enter a password each time.  To so so:

  • Download plink.exe, pageant.exe, and puttygen.exe from the Putty website.
  • Run puttygen.exe to generate a private and public key.
  • After the key has been generated, click on the “Save private key” button towards the bottom of the puttygen dialogue box.  Put it somewhere handy, you’ll need to refer to it later when calling your ssh client.
  • Towards the top of the window is a field that says “Public key for pasting into OpenSSH authorized_keys file:”  Login to your server where your Subversion repository resides.  Append this string to your home/.ssh/authorized_keys file (if it doesn’t yet exist, create it and add the key string).
  • Make sure that you chmod 600 your authorized_keys file so that it is only readable and writeable by the owner of the /home/.ssh directory, otherwise you won’t be able to use it to ssh to your server.

Start pageant.exe and load the private key you just generated. Copy a Pageant shortcut to “Startup” under the “All Programs” item on your Start menu. Add the path to your directory that contains plink:

  • Right-click on My Computer and select Properties
  • Click on the Advanced tab and click on Environmental Variables
  • Append the following to the Path System variables:
  • C:\Path\to\plink\dir
  • Restart your machine

Test:  From the command line type: plink.exe username@server If it is set up properly you’ll find yourself logged into your serve without a password prompt.

Next, we’ll configure Subversion to use plink for the ssh client.

  • Before you can edit the Subversion config file, you need to fire up a command line terminal and simply type svn.
  • You should get Type ‘svn help’ for usage.  That means Subversion in installed and ready to go.
  • Once you have done that, your configurations file will have been generated in your users Documents and Settings Directory.
  • Edit the Subversion config file for your user.  You should be able to find it under C:\Documents and Settings\username\Application Data\Subversion\config.
  • In some instances the Subversion directory isn’t created in Application Data directory for the user.  In that case, I’ve included a .zip file attached to this article entry.  Simply download the Subversion.zip file, unzip and place the folder in your C:\Documents and Settings\username\Application Data\ folder.
  • If you are running Windows 7 or Windows Server 2008 the folder will be C:\Users\username\AppData\Roaming\

Scroll down until you find the [tunnels]section. Add the following:  ssh=plink To add a configuration for the text editor program that you will use to enter notes with each svn commit command, add the following line:  editor-cmd = notepad That should do it.

Try checking out a copy from your repository.

  • Open up a Command Prompt and type:
  • svn co svn+ssh://user@server/path/to/repository dir_name_for_code
  • That should check out a version of your code from your repository and you should be good to to.

Leave a Reply