How do I set svn repository to private?

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.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.