Set Up Subversion (SVN) Repositories with svnserve on Debian 13 and Ubuntu 26.04
Serve Subversion repositories with svnserve on Debian 13 or Ubuntu 26.04: systemd service, users, path permissions, svn+ssh access and backups.
This guide sets up Subversion repositories on Debian 13 or Ubuntu 26.04 LTS and serves them with svnserve, Subversion's own lightweight server, over the svn:// protocol and over SSH (svn+ssh://). At the end you will have a dedicated svn system user, one or more repositories under /var/svn/repositories, per-user passwords and path permissions, and a systemd service that starts the server at boot. The same steps work on Debian 12 and Ubuntu 24.04 LTS.
svnserve needs no web server, which makes it a good fit for a small VPS. If you want access over HTTPS instead, Subversion is served through Apache with mod_dav_svn, which is a different setup.
Requirements
- A server running Debian 13 or Ubuntu 26.04 LTS (or Debian 12 / Ubuntu 24.04 LTS).
- A user with
sudorights (the examples usedeploy). - TCP port 3690 reachable from your clients for
svn://, or only SSH if you usesvn+ssh://.
All four releases ship the Subversion 1.14 series: 1.14.5 on Debian 13 and Ubuntu 26.04, 1.14.3 on Ubuntu 24.04 and 1.14.2 on Debian 12. The commands in this guide are identical on all of them.
Install Subversion
sudo apt update
sudo apt install subversion
The package contains the client (svn), the administration tools (svnadmin, svnlook) and the server (svnserve). It does not ship a service unit, so you will create one below. Older tutorials started svnserve from xinetd; with systemd that extra daemon is no longer needed.
Create the svn user and a repository
Run the server under its own unprivileged system account whose home directory holds the repositories:
sudo adduser --system --group --home /var/svn svn
Create a parent directory and the first repository as that user. Every repository you create under the parent directory is served automatically.
sudo -u svn mkdir /var/svn/repositories
sudo -u svn svnadmin create /var/svn/repositories/project1
Configure access
Each repository has its own settings in its conf directory. Replace /var/svn/repositories/project1/conf/svnserve.conf with the following. It refuses anonymous access, gives authenticated users write access, and points to the user and permission files next to it:
sudo -u svn tee /var/svn/repositories/project1/conf/svnserve.conf > /dev/null <<'EOF'
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = project1
EOF
Add users to /var/svn/repositories/project1/conf/passwd, one name = password line each under the [users] heading:
sudo -u svn nano /var/svn/repositories/project1/conf/passwd
[users]
deploy = use-a-long-random-password
alice = another-long-password
Passwords in this file are stored in plain text, so restrict it to the svn user and do not reuse passwords from other systems:
sudo chmod 600 /var/svn/repositories/project1/conf/passwd
Set path permissions in /var/svn/repositories/project1/conf/authz. rw means read and write, r read only, and an empty value means no access:
[/]
deploy = rw
* =
[/trunk/docs]
alice = rw
Here deploy can read and write everything, alice can only work below /trunk/docs, and everyone else is denied.
To share one user list between several repositories, give password-db and authz-db an absolute path such as /var/svn/conf/passwd in each repository's svnserve.conf.
Run svnserve as a systemd service
Create /etc/systemd/system/svnserve.service:
sudo tee /etc/systemd/system/svnserve.service > /dev/null <<'EOF'
[Unit]
Description=Subversion svnserve daemon
After=network.target
[Service]
Type=simple
User=svn
Group=svn
ExecStart=/usr/bin/svnserve --daemon --foreground --root /var/svn/repositories --listen-port 3690
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
--daemon --foreground makes svnserve listen for connections without detaching, which is what systemd expects. --root limits the server to that directory and removes it from the URLs clients use, so /var/svn/repositories/project1 becomes svn://your-server/project1. To bind to a single address, add --listen-host 203.0.113.10.
sudo systemctl daemon-reload
sudo systemctl enable --now svnserve
Open the firewall
If you use UFW, allow the Subversion port, preferably only from the addresses that need it:
sudo ufw allow from 198.51.100.0/24 to any port 3690 proto tcp
Use sudo ufw allow 3690/tcp to open it to everyone. Read the section on SSH below before you do that on a public server.
Verify
Check that the service is running and listening:
systemctl status svnserve
ss -tln | grep 3690
From a workstation with a Subversion client, query the repository. You are asked for the password from the passwd file:
svn info svn://203.0.113.10/project1 --username deploy
Create the conventional layout and check out a working copy:
svn mkdir svn://203.0.113.10/project1/trunk svn://203.0.113.10/project1/branches svn://203.0.113.10/project1/tags -m "Create standard layout" --username deploy
svn checkout svn://203.0.113.10/project1/trunk project1
Changes to passwd and authz apply to new connections without a restart.
Encrypt connections with svn+ssh
With the built-in password file, the password itself is not sent over the network in clear text, but file contents and commit data are not encrypted. For access across the internet, tunnel Subversion through SSH instead. The client then starts a private svnserve process over the SSH connection and port 3690 does not have to be open at all.
The simplest arrangement keeps one system account, svn, and gives every developer their own SSH key in it. Give the account a shell and an authorized_keys file:
sudo usermod -s /bin/sh svn
sudo -u svn mkdir -m 700 /var/svn/.ssh
sudo -u svn nano /var/svn/.ssh/authorized_keys
Add one line per developer. The command= option forces the key to run svnserve in tunnel mode and nothing else, and --tunnel-user sets the name recorded as the commit author and matched in authz. Each entry must be a single line:
command="svnserve -t --tunnel-user=deploy -r /var/svn/repositories",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-ed25519 AAAA...key... deploy@laptop
command="svnserve -t --tunnel-user=alice -r /var/svn/repositories",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-ed25519 AAAA...key... alice@workstation
sudo chmod 600 /var/svn/.ssh/authorized_keys
Clients now use the svn account in the URL, and their own SSH key identifies them:
svn checkout svn+ssh://svn@example.com/project1/trunk project1
The passwd file is not consulted for tunnelled connections, but the authz rules still apply. Because every process runs as the svn user, repository file permissions stay consistent. If you only use SSH, stop the network daemon and close the port:
sudo systemctl disable --now svnserve
Back up and maintain repositories
Do not copy a live repository with cp or rsync alone; use the tools that take a consistent snapshot.
sudo -u svn mkdir -p /var/svn/backup
sudo -u svn svnadmin hotcopy /var/svn/repositories/project1 /var/svn/backup/project1-$(date +%F)
A portable dump file, which can be loaded into any newer Subversion version with svnadmin load, is created with:
sudo -u svn sh -c 'svnadmin dump -q /var/svn/repositories/project1 | gzip > /var/svn/backup/project1.dump.gz'
Check a repository for corruption from time to time:
sudo -u svn svnadmin verify /var/svn/repositories/project1
Subversion itself is updated with the rest of the system through apt. The server chapter of the Subversion book documents every svnserve.conf option.
Troubleshooting
- "Authorization failed": the user is missing from
authz, or a later, more specific section denies the path. Remember that* =denies everyone not listed. - "No repository found": the URL path does not match. With
--root /var/svn/repositoriesthe URL starts at the repository name, not at/var/svn. - Commit fails with a permission error: something in the repository is owned by root, usually because an
svnadmincommand was run withoutsudo -u svn. Fix it withsudo chown -R svn:svn /var/svn/repositories. - The service does not start: read the reason with
journalctl -u svnserve. A port already in use or a typo in the unit file are the usual causes.
Frequently asked questions
Is Subversion still maintained?
Yes. The Apache Subversion project lists 1.15.0 as its current recommended release and still supports the 1.14 series that Debian and Ubuntu package. A 1.14 server works with older and newer clients.
Can I encrypt svn:// without SSH?
svnserve can use Cyrus SASL for authentication and encryption (use-sasl = true and min-encryption in the [sasl] section of svnserve.conf), with users managed by saslpasswd2 instead of the passwd file. It needs SASL support on every client as well, so for a small team svn+ssh:// is usually less work.
Should each project get its own repository?
Separate repositories give each project its own revision numbers, permissions file and backup, and are easy to move to another server. One shared repository with a directory per project makes it possible to move files between projects with history. With svnserve --root both layouts are served the same way.
Can developers have their own system accounts instead of sharing the svn account?
Yes: put the accounts in a common group that owns the repository and make sure every process that touches it runs with umask 002, otherwise files created by one user become unwritable for the others. The single-account setup with forced commands avoids that permission problem, which is why it is used here.