How to get SVN+SSH Working on Windows with a CLI SVN Client


As part of our ongoing automation efforts I was in need of setting up a script to automatically setup a few dev machines. One key step was automating the SVN Update process to ensure we had the latest source code from the mainline development group. As their SVN server uses SVN+SSH we needed to tweak our clients to get this to work in an automated fashion

While the Linux machines were simple to setup, we had more issues with the Windows machines. All the Windows machines had TortoiseSVN installed, which is an excellent GUI SVN Client- but does not provide CLI tools for automation. I had to come up with another solution to get SVN+SSH working at the command line on the windows boxes.

Notes:
  • SVN+SSH on Windows with OpenSSH [dnorth.net]
  • I had tried some similar things (editing the config file to change the ssh client), but they didn't work. The above article was excellent and helped me put together a working system!



How to install CLI SVN Client for windows and get SVN+SSH Working

  1. Install collabnet CLI SVN client
    1. http://www.collab.net/downloads/subversion
      NOTE: Login is required to obtain the download
       
  2. Verify installation
    1. Open a command prompt and run svn help

      If it installed correctly you will see help text for the svn command

      NOTE: You may need to close and re-open your command prompt if you see a libapr error

  3. Ensure you have a public/private keypair created in c:\Users\username\.ssh
    Note:
     It is important to put it in your windows username directory to minimize configuration later on 
     
  4. Install Cygwin + OpenSSH Package (See this related BoredWookie article)
     
  5. Edit the svn config file found here C:\Users\username\AppData\Roaming\Subversion\config

    and add a line like this (Be sure to edit for your username):

    ssh = c:/{cygwin root path}/bin/ssh.exe -i "C:/Users/{username}/.ssh/id_rsa"

    Note: In my case id_rsa was the name of my private key
     
  6. Try doing a simple svn+ssh list command to see if it works:

    svn list svn+ssh://username@svn/source
 
At this point everything should 'just work'

As part of our ongoing automation efforts I was in need of setting up a script to automatically setup a few dev machines. One key step was automating the SVN Update process to ensure we had the latest source code from the mainline development group. As their SVN server uses SVN+SSH we needed to tweak our clients to get this to work in an automated fashion

While the Linux machines were simple to setup, we had more issues with the Windows machines. All the Windows machines had TortoiseSVN installed, which is an excellent GUI SVN Client- but does not provide CLI tools for automation. I had to come up with another solution to get SVN+SSH working at the command line on the windows boxes.