SVN: How do you use svn command line on Windows with ssh tunneling?

If you ever used svn command line, you know it is not optimal to type in your password every time you do checkout, checkin, info, etc.  In linux world, it is very easy to setup keys to get around this.  Of course in the world of Windows it is not as easy.  Here are the steps you need to follow to get private/public keys working with your SVN under Windows using ssh tunneling.

Assumptions:  you will be connecting as user “root” to svn server located at “10.0.0.1”.  All your files will be saved at c:\ including your svn command line utility

First we will have to generate a key.  We can accomplish this by using a free utility called puttygen.  Run puttygen and click on “Generate” button.  You will have a key similar to below example:

Example of a key generated by puttygen

Example of a key generated by puttygen

Copy this, you will need it in few mins.  At this point, go ahead and create a private key by clicking on:  “Save private key”.  Save this as private.ppk on your C:\. 

Now let us log in to the svn server and add this public key to the authorized_keys2 (see setting up keys for step by step instructions).  I will assume you are using “root” as login.

vi /root/.ssh/authorized_keys2

Make sure when you paste, it is not broken into different lines.  All of the key should be one line.

Ok now back to your Windows machine.  Now we need to set up ssh tunnel to our server.  There are few ways of doing this but for our purpose, we will use another free program provided by the same developers as puttygen: download plink to C:\.  If you do not do this step, you will get following error:

svn: Can't create tunnel: The system cannot find the file specified.

Ok let us set the variables for svn.  Go to command prompt and type (you can also set this in your scripts and inside windows environment.  But since this post is to show you an example, we will just do this):

set SVN_SSH="/plink.exe" -i /private.ppk -l root

Now let’s run this one time manually to cache key:

/plink.exe -i /private.ppk -l root 10.0.0.1

Press “y” when it asks you to save.  Type exit and get back to your prompt.

Ok now we can test our svn utility.

/svn info svn+ssh://10.0.0.1/svn/testrepo/trunk/

This should display output similar to:

Path: trunk
URL: svn+ssh://10.0.0.1/svn/testrepo/trunk
Repository Root: svn+ssh://10.0.0.1/svn/testrepo
Repository UUID: b9143312-b1a1-11ba-a111-11cdcd1d2222
Revision: 10
Node Kind: directory
Last Changed Author: root
Last Changed Rev: 4
Last Changed Date: 2008-11-18 15:18:47 -0800 (Tue, 18 Nov 2008)

Now you are ready to script your checkouts, do checkin’s with out having to type in your password, etc.

————————————-
DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.

3 thoughts on “SVN: How do you use svn command line on Windows with ssh tunneling?

  1. golden goose sneakers

    I have to show my appreciation to you just for bailing me out of this dilemma. After looking out throughout the world-wide-web and seeing strategies which are not beneficial, I thought my entire life was well over. Being alive without the solutions to the issues you have solved all through your main short post is a crucial case, as well as the kind that could have negatively affected my entire career if I had not discovered the website. Your own personal skills and kindness in touching every item was precious. I am not sure what I would’ve done if I hadn’t discovered such a subject like this. I can at this time look ahead to my future. Thanks a lot very much for the specialized and results-oriented help. I will not think twice to endorse your blog to any individual who needs to have guidelines about this subject.

  2. ferragamo belt

    I enjoy you because of all of the work on this site. My mother really likes setting aside time for investigation and it’s simple to grasp why. A lot of people hear all of the dynamic tactic you offer useful ideas via this blog and inspire participation from visitors on that matter plus our princess is without question starting to learn a whole lot. Have fun with the remaining portion of the new year. Your doing a first class job.

Leave a Reply

Your email address will not be published. Required fields are marked *