CHAPTER 17 ■ VERSION CONTROL WITH SUBVERSION
The second line in the previous fragment causes all directories created here to take on the svnusers
group. Accessing the Subversion Repository
In order to access a project within a subversion repository, you must use a URL to specify its
location. I’m going to jump the gun now and pretend that I’ve already created a project named megaquiz.
Another sneak peak is a subcommand called list (or ls for short), which lists the files at a location
within a repository:
$ svn ls file:///var/local/svn/megaquiz
As you can see, a Subversion URL looks very much like the kind of thing you would type into a
browser’s location field. It consists of a scheme (the kind of connection you’d like to make), possibly a
server name, then a path, which includes the repository location followed by any number of project
directories. Because the fragment above specified the filesystem in its scheme, there was no need to
provide a server.
Assuming the repository machine is running sshd, and that the firewall is properly configured, I
could also access the same repository from a remote machine using ssh:
$ svn ls svn+ssh://localhost/var/local/svn/megaquiz
Subversion handles a number of other modes of communication. Depending on how the repository
server is configured, you may also be able to use the WebDav protocol (the http or https schemes) or the
svn network protocol (the svn scheme). Now that I’ve set up the Subversion repository on the server, I’ll
stick to ssh (more properly this is the svn protocol tunneled over ssh, hence the compound scheme
svn+ssh), apart from some issues discussed below, is an easy and secure communication mechanism.
Setting up Subversion for working with SSH is trivial. If your server is configured to accept ssh
connections, then the repository is accessible as above. There are a couple of annoyances, however. It is
hard, for example, to allow users full access to your repository without first giving them a shell account
on the Subversion machine. If you are allowing nontrusted users, you could look into setting up a chroot
jail, which supports an extremely restricted environment for user accounts. This strays too far into the
realms of system administration for this chapter! A simpler solution is to disable login access for any
users you don’t want to have command line access. You can do this when you create the user’s account.
Check the man page for the adduser command for more details.
Also annoying for users is the requirement to continually type in their password or pass phrase for
every Subversion command. I have already set up the user bob on the Subversion machine, so he has
remote access to the repository using the svn+ssh scheme. How can I make it easier for him to
authenticate himself, though? The finer details of SSH configuration are beyond the scope of this book.
■Note Pro OpenSSH by Michael Stahnke (Apress, 2005) covers SSH comprehensively.
In brief, though, Bob should generate a public key with a program called ssh-keygen on his client
machine. He will be prompted to create a pass phrase. He should copy the generated public key, which
he will find in .ssh/id_rsa.pub (where .ssh is in his client home directory), and append it to a file called
.ssh/authorized_keys (where .ssh is in his home directory) on the Subversion server. He can now use a
program called ssh-agent to handle the details of authentication for him.
Beginning a Project
To use Subversion on a project, you must add that project to the repository. You can do this by
importing a project directory and any contents you might already have.