This is a quick guide on how to setup subversion using svn+ssh. svn+ssh lets us tunnel a subversion session over the secure SSH protocol, which means all data and passwords are encrypted. I like setting subversion up this way because:
This was done on CentOS, but the instructions apply to most any OS.
yum install subversion
/var/svn/reposis a good place. Call your repo whatever you want; I used 'my_code':
mkdir /var/svn mkdir /var/svn/repos svnadmin create /var/svn/repos/my_code
svngroup, and give access to anybody who needs to access subversion.
chown -R :svn /var/svn/repos/
chmod -R 775 /var/svn/repos/
svnserveis the server component of subversion; when your subversion client connects via SSH, it spawns an instance of
svnserverunning under your user account. The problem here is the 'under your user account' part; that means it is running under your user account's permissions setup. By default, your permissions don't allow anyone else access to your files, and yet
svnserveis going to be writing files in the common user directory at
/var/svn/reposthat everyone needs write access to. Therefore, we can create a wrapper script that sets a
umaskfor group-writable peermissions right before svnserve is called:
#!/bin/sh # set the umask so files are group-wriable umask 002 # call the 'real' svnserve, also passing in the default repo location exec /usr/bin/svnserve "$@" -r /var/svn/repos
Save this somewhere, like
/var/svn/svnwrapper.sh. Make a symlink in
cd /usr/local/bin ln -s /var/svn/svnwrapper.sh svnserve chmod 755 /var/svn/svnwrapper.sh
Update 2 Dec 2010: Per the comments from Fred & Timothy Boronczyk, I now recommend that you put the symlink in
/usr/local/bin rather than
/usr/bin as I originally recommended. This means you avoid having to move the original
svnserve binary in
/usr/bin. The above scripts have been updated to reflect this new approach.
mkdir code mkdir code/trunk mkdir code/tags mkdir code/branches svn import code svn+ssh://USERNAME@SERVER/my_code -m 'inital import' rm -rf code
That's it. The server is now setup.
svn co svn+ssh://USERNAME@SERVER/my_code my_code_local_dir
In reality, you'll probably want to use a fancy graphical client like TortiseSVN (Windows) or Versions (OS X) to access your subversion server. Getting those setup is beyond the scope of this document, but there are many excellent tutorials.