Cameron Yule

Multiple users with svn+ssh

Following on from my last post on moving from svnserve to svn+ssh, I had to then get this setup working for multiple users. This is how I achieved it on CentOS 5.2, hopefully it’ll prove useful for someone else.

This is based on a tutorial I found on the subversion dev mailing list.

# We need a group for our svn users
groupadd svnusers
 
# Add the users
useradd svn -g svnusers # this is the svn 'admin' user
useradd user1 -g svnusers
useradd user2 -g svnusers
useradd user3 -g svnusers
useradd user4 -g svnusers
# … etc
 
# Edit each svn user's .bashrc file, e.g.
su - user1
nano -w .bashrc
 
# Add the followng line to the bottom
umask 002 # allow user + group to write, no other. 
 
# Create the dir where we're storing the repo (as root)
mkdir -p /usr/share/subversion/repositories
 
# Set permissions on our new dir
chown -R root.svnusers /usr/share/subversion/repositories
chmod -R u+wrx,g+wrx,o-wxr /usr/share/subversion/repositories
chown -R root.svnusers /usr/share/subversion
 
# The following may be overkill
# chown -R root.svnusers /usr/share
 
# Rename the original svnserve command into svnserve.bin 
mv /usr/bin/svnserve /usr/bin/svnserve.bin
 
# Create a new svnserve file
nano -w /usr/bin/svnserve
 
# Paste the following into nano and save as svnserve
#!/bin/sh 
# wrap in order to put root in by default 
# Script implemented by Adrian Robert <arobert @cogsci.ucsd.edu> 
exec /usr/bin/svnserve.bin -r /usr/share/subversion/repositories "$@"
 
# Make our svnserve wrapper executable
chmod u+wrx,g+rx-w,o+xr-w svnserve
chmod u+wrx,g+rx-w,o+xr-w /usr/bin/svnserve
 
# Log in as the svn user
su - svn
 
# Create our repos
svnadmin create /usr/share/subversion/repositories/projects
cd /usr/share/subversion/repositories/projects/conf 
 
# Edit the repo conf
nano -w svnserve.conf
 
# Add the following under the [general] header
anon-access = none
auth-access = write

Published on July 11, 2008 in Server
Tags: , , , ,

Comments

Join the discussion by leaving a comment, or trackback from your own site.

Andrew commented on 11/07/2008:

Funnily enough this is the approach I was going to take for multiple users accessing a private git repo — you’ve just worked out the details for me. Cheers!

Cameron commented on 11/07/2008:

Sharing the knowledge works! ;)

Andrew commented on 11/07/2008:

Aye, true dat. My problem is that I think that other smarter people must have solved the problem I’ve solved before, so I don’t blog about it…

Perhaps a writeup on my capistrano/staging modifications may rock the world :)

Cameron commented on 11/07/2008:

If you do, you should have a look at this :)

Leave a comment

Comments are moderated, so be nice!