Quick and Dirty Subversion Repository with SSH

Posted on in Software

If you've ever needed to set up a Subversion repository, you know how long it can take to get WebDAV working with Apache before you even get to the repository set up. Although WebDAV is the best overall protocol for Subversion repositories (it doesn't require real users on the system, for one thing), in a pinch you can set up a Subversion repository that works via SSH. If all the developers that need the repository already have users on the system, then there's really no harm done.

  1. Create the Subversion repository on the server. Choose a directory where the repository should stay, perhaps /var/svn. Then sudo svnadmin create /var/svn to create the subversion repository.
  2. Assign the directory to your developer group and change the permissions accordingly. If your developer group is dev, then sudo chgrp -R dev /var/svn and sudo chmod -R g+w /var/svn will get the job done. Since the repository users will be real system users, it's important that they all have write access to the repository.
  3. Set umask to 002. Since multiple users will need to access this repository, all files will need to remain group writable. Setting umask 002 to each users login profile will ensure that files remain group writable.
  4. Import your existing data into the repository. If you have an existing file structure on the server, you can import that into the repository with the svn import command. Remember that the command will create necessary data structures, so feel free to spice things up a bit. For example, to import a directory called "Projects" simply svn import ./Projects file:///var/svn/ and the "Projects" directory will be automatically created in the Subversion repository. It's important to note that the file:// syntax requires three (3) '/' to signify there is no hostname.
  5. Check out working copies on remote workstations. In order to check out their working copy, each developer should run svn co svn+ssh://server_name/var/svn/Projects Projects in the directory where they want the Projects workspace to live. It's worth noting that the svn+ssh:// protocol requires the full path to the Subversion repository since it's using SSH to make the transfer.
  6. Get to work! Now you've done it. Developers should be comfortable with working from this point. As far as they're concerned, there is no difference between Subversion over SSH and Subversion over WebDAV.

That should be enough to get you started. If you have any questions, let me know!

My Bookshelf

Reading Now

Other Stuff