How do I set svn repository to private?

November 29, 2015 549 views
Security Ubuntu

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.

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.

Have another answer? Share your knowledge.