How To Setup a Windows SVN Repository |
This is a tutorial on how to setup a Subversion (SVN) repository on Windows that allows secure connections over SSH. The tutorial also goes through setting up an SVN client and connecting to the repository. Some basic knowledge of a UNIX based command line will help, but you might be able to muddle through without it.
If you plan on storing the repository on the development machine (normally only useful if you are a lone wolf developer and always use the same development box), this tutorial will be more complicated than you need.
This tutorial was tested with the repository installed on Windows Server 2003, and the SVN client on Windows XP, although the process is pretty much the same on any version of Windows.
Install Cygwin
Cygwin is linux-like environment for Windows. It gives you a terminal much like you would find on any *nix based system, and is one of my favorite development tools.
Download Cygwin, and install it on the server. You can keep all of the defaults for Installation Type, Installation Directory, etc. The only thing you need to change is the packages selected for install. Keep all of the packages that are initially selected, plus select ‘openssh’ from the Net category, ’subversion’ from the Devel category, and ‘cygrunsrv’ from Admin.
Install the SSH Daemon
The SSH daemon provides secure communication between the client and server. It will be used to encrypt any updates that are made to the repository.
In order to install it, make sure you are logged in as an Administrator. Open Cygwin and run
-
ssh-host-config -y
to run the ssh config script.
when it asks for the value of the environment variable CYGWIN, type ‘ntsec tty’
If you see warnings or errors related to file permissions, run the following lines, then rerun the config script. Note that I’m no security expert, so please take these directions with a grain of salt.
-
chmod +x /var
-
chmod +rw /etc/group
-
chmod +rw /etc/passwd
Once ssh-host-config finishes with the info message ‘Have fun!’ the ssh daemon is configured.

Depending on your system, you may run into something like this instead:

The daemon was successfully configured, but for some reason privilege separation failed. If you are happy with a slightly less secure system, you can go ahead and use it this way. And if anyone knows how to fix this issue, please let me know.
Go ahead and start it up with
-
cygrunsrv -S sshd
Test the setup by running
-
ssh localhost
which should now allow you to log in with your Windows password.
Create the SVN Repository
Inside of Cygwin, run the following command to create a repository called svn inside the home directory:
-
svnadmin create /home/svn
If you are restoring the repository from another location, run
-
svnadmin load /home/svn < <dumpfile-name>
Setup a Client
Now that the server is setup, lets checkout the code onto a development machine.
Start by installing Cygwin on the dev box. Installing using the default options works fine, and go ahead and select the same packages used in the server installation.
Open cygwin and run
-
svn co svn+ssh://<username>@<your server name or IP>/home/svn
Remember to fill in your own details - here <username> is the username on the server machine.
Setup Additional Users
You will want to create a seperate user for everyone who will be commiting to the repository.
Create a new Windows user on the server, here we will create the user ‘devel’. The username can be whatever you choose, but avoiding spaces and punctuation characters in the username might make your life easier down the road, since cygwin can sometimes choke on weird usernames. As a generally good security practice, the new user should not be an administrator, it should have limited rights, and it should have a strong password set.
Here are instructions for creating a user for Windows Server 2003.
Now we need to let Cygwin know about the new user. To do so, run these commands:
-
chmod u+w /etc/passwd
-
chmod u+w /etc/group
-
mkpasswd -l > /etc/passwd
-
mkgroup -l > /etc/group
The user devel will now have access to the repository. Check by running
-
svn list svn+ssh://devel@<your server name or IP>/home/svn
Thats all there is to it!
Related |
|





[...] How To Setup a Windows SVN Repository | GrokCode This is a tutorial on how to setup a Subversion (SVN) repository on Windows that allows secure connections over SSH. The tutorial also goes through setting up an SVN client and connecting to the repository. Some basic knowledge of a UNIX based command line will help, but you might be able to muddle through without it. [...]
Or, just download and install VisualSVN….a free one-click installation program for Subversion and Apache for Windows:
http://www.visualsvn.com/server/
I use this and it’s bullet proof and simple.
@Dave That looks like a great tool. Does it work if Apache is already installed on the server?
@Jess Not sure….but why don’t you just try it? It only takes 2 minutes to install all this and it works like a charm for me. It’s a fantastic tool….I’ve got it installed on my Windows Home Server appliance (HP Mediasmart) serving my SVN needs (I might also add that WHS also has IIS server running on the standard ports, so that tells me that VisualSVN installs with non-standard ports and should probably work just fine if you already have Apache installed.
in the beginning you are granting read privilege to /etc/password (chmod +r /etc/passwd) and the ssh-host-config script failed with “created new user sshd, but failed to add corresponding entry to /etc/passwd” - the solution could be running “chmod +rw /etc/passwd” before ssh-host-config.
@alexandrul Thanks! I forgot to put that in. I’ve updated the tutorial.
@jess: Yes, VisualSVN is free&fantastic. Does not matter if apache is already installed, VisualSVN installs
to separate directory and if I remember correctly you can choose port for apache during installation (or at least later after installation in apache config), SSL is also installed by default.
It’s really 1 minute installation and VisualSVN also comes with ’server manager’ which allows you create repositories, users, groups, permissions.
Jozef
i bookmarked this article….thank you
[...] SVN repository on a Linux Ubuntu server, then follow these instructions. For Windows, use these instructions as guidelines; however, I have not personally tested these procedures. For those who use Mac as a [...]
Hello Guru, what entice you to post an article. This article was extremely interesting, especially since I was searching for thoughts on this subject last Thursday.
Thanks
As a Newbie, I am always searching online for articles that can help me. Thank you
That’s all there is to it? I think not. This is a horrible tutorial meant only for people with fair knowledge of UNIX.
@Nixx
Covering basic unix commands and their usage is really beyond the scope of this tutorial, but if you can’t get it working you have a few options:
1 - Follow the recommendation of a the kind folks who left comments above and install VisualSVN
2 - Learn some basic unix commands
3 - Curse that damn unix and this horrible tutorial!
Some options are more effective than others.