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:
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.
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:
Repository Root: svn+ssh://10.0.0.1/svn/testrepo
Repository UUID: b9143312-b1a1-11ba-a111-11cdcd1d2222
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.
You can also use bzr (http://bazaar-vcs.org/) or GIT to talk with an svn repository.
This also enable future migration to a distributed model, and real merges without headaches.
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.
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.