All the required packages are available in the Ubuntu repositories.
Use apt-get:
sudo apt-get update sudo apt-get install subversion
Let's say you want your repository to be in /var/svn/repos, type in these commands:
cd /var sudo mkdir svn sudo svnadmin create /var/svn/repos
In order to control who has access to the repository we will now add a user who will own the repository files. Adding a user also adds a group with the same name.
sudo adduser svn
Now make it impossible for anyone to log in as this user by editing /etc/passwd to set the svn user shell to /bin/false. Do this using the vipw command. Find the line which starts svn (it should be the last line in the file) and change /bin/bash to /bin/false.
Now change the ownership of the repository files.
sudo chown -R svn.svn svn
In order for someone to be permitted to use the repository they must be added to the svn group. My user name is martin so I am going to add myself to the svn group.
sudo vigr
Go to the end of the file and add your user name to the end of the line which starts svn. The end of the file should look similar to this:
admin:x:110:martin svn:x:1001:martin
Now set up an ssh server, clients will connect to this machine using ssh:
sudo apt-get install openssh-server
The repository can now be accessed using the svn+ssh protocol. Test this as follows:
svn co svn+ssh://username@machinename/var/svn/repos
You will be prompted about the RSA fingerprint of the server and asked for your password. You should end up with a directory called repos which is a working copy of your new repository.
As things stand you will be asked for your password every time you connect to the machine which is rather tedious. You can also authenticate with ssh by using a public/private key pair. If you are using a Windows client then install PuTTY and use PuTTYgen to create a key. Don't forget to save the public and private key files. There is a text box at the top of the PuTTYgen window labeled "Public key for pasting into OpenSSH authorized_keys file", you need to put the line of text in that box into a file called .ssh/authorized_keys2 in your home directory on the server. Set the permissions on the files like this:
chmod 0700 .ssh chmod 0600 .ssh/authorized_keys2
On the Windows machine fire up pageant (another program which comes with PuTTY) and load your private key. You should now be able to connect to the server without being asked for a password. I prefer to disable password based access to the server by editing /etc/ssh/sshd_config and adding the line PasswordAuthentication no.
On a Linux client use ssh-keygen to create the key pair.
Subversion also supports the WebDAV protocol, to set this up Apache is needed. I am assuming that you installed Ubuntu as a LAMP server.
sudo apt-get install libapache2-svn
The following isn't recommended for a real implementation as we are going to add to the default web files. It would be far better to create a new virtual host, but that is a subject itself.
Ubuntu has a file for each active virtual host in /etc/apache2/sites-enabled, after installing Ubuntu server there will be a file called 000-default in the sites-enabled directory and this is the file we are going to edit.
cd /etc/apache2/sites-enabled sudo vi 000-default
In the
<Location /svn/repos>
DAV svn
SVNPath /var/svn/repos
</Location>
Then execute this command:
sudo /etc/init.d/apache2 force-reload
You should now be able to see the repository at the URL http://machinename/svn/repos.
Add this to the location directive:
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/passwords
Require valid-user
Now add a user name and password to the Apache password file:
sudo htpasswd -cb /etc/apache2/passwords martin dgjan08
And another forced reload:
sudo /etc/init.d/apache2 force-reload
Now if you visit the repository URL you will have to enter a valid user name and password.
Trac is a ticketing system and Wiki which integrates very well with Subversion. Start by installing Trac:
sudo apt-get install trac python-setuptools libapache2-mod-python enscript
Now create a Trac database:
sudo mkdir /var/www/trac sudo trac-admin /var/www/trac/repos initenv
Then answer its questions, take the defaults, our Subversion repository is in /var/svn/repos.
Now to get Apache to run Trac.
cd /var/www sudo chown -R www-data.svn trac
Head back to /etc/apache2/sites-enabled and edit 000-default again, adding this:
<Location /trac/[[:alnum]]+/login">
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/passwords
Require valid-user
</Location>
<Location /trac>
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/www/trac
PythonOption TracUriRoot /trac
</Location>
And then run this again:
sudo /etc/init.d/apache2 force-reload
If you want the most recent version of Trac (0.10.4) then you will have to build and install it. Do the following:
sudo apt-get remove trac wget http://ftp.edgewall.com/pub/trac/trac-0.10.4.tar.gz tar zxf trac-0.10.4.tar.gz cd trac-0.10.4/ sudo mkdir /usr/local/trac sudo python setup.py install --prefix=/usr
The rest of the instructions are the same.
Adding New Users
Hi guys,
I am new to SVN. This is the first time I have installed SVN though i have been using it earlier. I have installed SVN on Ubuntu & using Tortoise SVN on Client computers (Windows) to access repository. At present, I am only able to log using the initial account i created. I want to add more users to SVN so that what ever repository i create, any one (authenticated users) can checkout that repository.
My SVN folder has group name "Nitin" and owner is "SVN-Nitin". Please tell me hoe can I create more user accounts with there individual passwords (every user id will be associated with a passsword)
I tried creating a user account with password. Whenever I checkout a repository with that user id and password, it is successful. But when ever I make modifications in a file present is repository or try adding a new file, it says "Can't open file '/var/svn/myproject/db/txn-current-lock': Permission denied"
--------------------------- PLEASE HELP ----------------------
Adding the user
Here's the command I used to add the user
sudo adduser --system --no-create-home --group svn
That gets you the no-password thing, uses the right UIDs for system accounts, and skips creating the home directory.
svn+ssh
I think that for svn+ssh to work successfully, your ssh connection must be made as a user who has write access to the repository.
In the example above, you could read from the repository (e.g. checkout) as any user in the svn group, but you could not write to the repository (e.g. commit) unless you connected as user svn.
If you try to commit to the repository as a different user you will get an error like:
Can't create directory '<path_to_repository>/db/transactions/1-1.txn':Permission denied
I wrote a bit about it at http://sudocode.blogspot.com.
Add the user to the svn group
The instructions do address this, all you have to do is add users to the group
svnand they will have the required permissions.sudo chmod -R 775 svn
Great tutorial, but I had the same problem as the others,
Can't create directory '/db/transactions/1-1.txn':Permission denied
What I needed to do was the following:
/var$ sudo chmod -R 775 svnbecause the members of the group svn only had read and execute permissions, no write permissions
Cheers
SVN Commit error
Restart the server and login as root in console go to the folder /usr/bin type svnserve -d to restart the SVN dameon,It worked for me.Good luck.
Permission denied using Apache
Hi,
This guide is excellent, but from my perspective, a step was missing for the Apache setup.
Since normally the Apache user is www-data, this user must be granted access to the repository files:
chown www-data:www-data /var/svn/repos -R
chmod g+w /var/svn/repos -R
That way the operations done through an Apache connection (from any SVN client) will be permitted.
Problems, installing subversion
Hi,
I'm getting into some trouble when setting up subversion using your guide.
That's the error message which occurs when i want to access the svn.
dbs@dbs-mobile:/var$ svn co svn+ssh://dbs@dbs-mobile/var/svn/repos/dbs@dbs-mobile's password:
svn: Can't open file 'repos/.svn/lock': Permission denied
dbs@dbs-mobile:/var$
Any ideas? My Account 'dbs' is already member of the svn group.
Thanks in advance,
dbs
You need to change directory
You appear to be trying to check out into /var and you won't have permission to do that.
Try
cd ~followed by your checkout command.Problems when commiting
Hi!
I've followed exactly the instructions here (of course adapting the dirs for my project...) but when i want to commit i have this error:
Añadiendo trunk/archivoPrueba.txt
Transmitiendo contenido de archivos .svn: Falló el commit (detalles a continuación):
svn: No se puede crear el directorio '/var/svn/ADMSolution/db/transactions/1-1.txn': Permiso denegado
svn: Su mensaje de commit fue dejado en un archivo temporario:
svn: '/home/gustavo/Temporal/ADM/ADMSolution/svn-commit.2.tmp'
Is, permission denied.
What happen? the user i am using to commit is on svn group as well.
NOTE: using Ubuntu Gutsy of course.
Thanks in Advance
Which transport?
Are you using http:, svn: or file: for the URL to the repository?
i am Using SVN+SSH Cheers.
i am Using SVN+SSH
Cheers.
trac authentication instructions
I think there's a mistake in your instructions for connecting trac to svn on Ubuntu Gutsy Gibbon.
At least this doesn't work for me:
but this does: