How do I set svn repository to private?

Posted November 29, 2015 4.3k views

I got an SVN repository installed on my vps, but it is publically accessable, how do I make it private? I.e, requires a password to read the content.

Writing isn’t an issue as a password is already needed for that anyway.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

How did you setup the svn repository? It sounds like you are serving it over HTTP with Apache perhaps?

I find the easiest way to server a private repo is to use the svn+ssh:// protocol rather than HTTP. That way, you can manage access to it via a normal user account. For instance, if we wanted to set up an svn user:

  • sudo adduser svn
  • cd /home/svn/
  • sudo -u svn mkdir project
  • sudo -u svn svnadmin create /home/svn/myproject

You would then be able to access it with the same password you set when running adduser svn when running:

  • svn co svn+ssh://svn@

You can also add SSH public keys to /home/svn/.ssh/authorized_keys in order to grant access to the private repo without sharing the password.

If you are allowing others to use the repo, you’ll want to make sure that the svn user can’t log in to the server itself and only be used via svn+ssh://

Edit the file /etc/ssh/sshd_config and append:

Match User svn
  ForceCommand /usr/bin/svnserve -t

Finally, restart SSH for the changes to take effect:

  • sudo service ssh restart

This wiki page goes over a few other options as well.