Report this

What is the reason for this report?

How do I set svn repository to private?

Posted on November 29, 2015

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.



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!

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.

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@159.203.24.122/home/svn/myproject

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.