$ sudo apt-get install subversion websvn enscriptThe websvn package is a great tool for viewing the revisions of a subversion project; its installation causes the package configurator to run. Take all the defaults (just hit Enter), telling it to not configure it now. We'll configure it by hand. Create the general subversion repository directory:
$ mkdir ~/svnThe key files are in the /etc/websvn package. The suggested Apache configuration needed to run websvn is within the directory.
$ sudo cp /etc/websvn/apache.conf /etc/apache2/conf.d/websvn.confEdit /etc/apache2/conf.d/websvn.conf. Make this the content of the Directory element be:
<Directory /usr/share/websvn> DirectoryIndex index.php Options FollowSymLinks Order deny,allow Allow from 127.0.0.1 </Directory>Reload Apache. Next, we have to do several edits on the main WebSVN config file:
/etc/websvn/config.phpStart an editor for this file, and:
// $config->parentPath('Path/to/parent (e.g. c:\\svn)');
Just below that line, create this one (uncommented):
$config->parentPath('/home/LOGIN/svn');
?>
<?php
if ( file_exists("/etc/websvn/svn_deb_conf.inc") ) {
include("/etc/websvn/svn_deb_conf.inc");
}
?>
Remove the 3 Php "tag" lines you see, getting:
if ( file_exists("/etc/websvn/svn_deb_conf.inc") ) {
include("/etc/websvn/svn_deb_conf.inc");
}
$config->useEnscript(); $extEnscript[".cgi"] = "perl"; $extEnscript[".pl"] = "perl"; $extEnscript[".pm"] = "perl"; $extEnscript[".html"] = "html";
$ svnadmin create ~/svn/authlogThen, take a look at the WebSVN website: You should see authlog hyperlink listed as the only subversion repository. Click on this link and you should see revision 0 (Rev 0) revealed.
$ cd ~/public_html $ svn co file:///home/LOGIN/svn/authlog Checked out revision 0.Note the "///" syntax common to using the "file" protocol to specify a URL. The "Checked out revision 0" feedback confirms what we see in WebSVN. The "co" is a shortened substitution for "checkout". Then,
$ cd authlog $ ls -aThe ".svn/" directory is the important subversion configuration directory.
$ svn add * $ svn commit -m "initial files"Refresh the WebSVN website. You should see revision 1 revealed with the files added.
$ ll /var/log/auth.log (observe permissions) $ groups (the groups I belong to, observe adm)Create a new log entry by attempting an invalid ssh login to the local system:
$ ssh foo@localhost foo@localhost's password: whatever Permission denied, please try again. foo@localhost's password: Ctrl-CImmediately click the View button in the web application to reveal the log lines generated by the failed login.
1: ... sshd[13272]: Failed password for invalid user foo ... 2: ... sshd[13272]: pam_unix(sshd:auth): authentication failure; ... 3: ... sshd[13272]: pam_unix(sshd:auth): check pass; user unknown 4: ... sshd[13272]: Failed none for invalid user foo from ::1 ...
$ svn commit -m "add filtering"Refresh the authlog project in the WebSVN site to see the effect. Click on the Compare Changes link on the right-hand side to see how this tool lists changes.
$ svn up -r 1 $ svn infoRefresh the authlog web application to confirm that you've reverted your local copy to revision 1 (the subversion site is still 2). OK, now let's go to the latest revision.
$ svn updateRefresh the authlog web application to confirm that you're at the latest revision.
$ svn up -r 1 getlog.cgiWhen you add or remove a file from the project you must inform subversion. These are the relevant commands:
$ svn add NEW-FILE $ svn delete OLD-FILE
Order deny,allow Allow from 127.0.0.1If you want external access, you need to protect it by using authentication. Follow the steps outlined in the Web Authentication + HTTPS document.
For example, this content was extracted from a recent version of the developer's page used for the Ardour software (an open source digital audio workstation):
SVN/Bleeding Edge accessArdour uses Subversion ("SVN") as its distributed development repository tool. Public read access is available to all, but only specific developers have write access.Browsing the source codeYou can use your web browser to read the source code directly from the repository.Public read-only SVN accessOnce you have subversion installed, you can checkout the source code to Ardour with this command:svn co http://subversion.ardour.org/svn/ardour2/branches/2.0-ongoingNote that this will fetch the branch corresponding to the current release in the 2.X series, rather then the bleeding-edge development version. If you are an active developer of Ardour, or a beta tester who can live with random crashes while testing out cool new functionality, you can get the development version using this command: svn co http://subversion.ardour.org/svn/ardour2/branches/3.0 Developer (write) access to SVNFor developers that have been granted write access and have supplied a public SSH key, this command will checkout Ardour so that you can work on the software and commit your changes:svn co svn+ssh://ardoursvn@ardour.org/ardour2/branches/3.0 |
$ sudo a2enmod dav dav_lock dav_fsAn Apache configuration file which uses the ~/svn/authlog project would look something like this:
<Location /svn/authlog> DAV svn SVNPath /home/LOGIN/svn/authlog </Location>Without other alterations, this would provide anonymous checkout capabilities with the http protocol using one of these statements:
$ svn co http://localhost/svn/authlog $ svn co http://MACHINE.cs.wcupa.edu/svn/authlogAs in other situations, the access may be protected by authentication. If the project directory is made writeable by the Apache user like this:
$ sudo chgrp -R www-data ~/svn/authlog $ sudo chmod -R g+w ~/svn/authlogthen developers would be able to make changes (import, commit, etc) using the http protocol. If we were to use this scheme, we definitely would want to employ some authentication mechanism.
$ cd ~/.ssh $ cat id_dsa.pub >> authorized_keys2You must be able to ssh to yourself without password:
$ ssh localhostWith that in place, one would simply do:
$ svn co svn+ssh://LOGIN@localhost/home/LOGIN/svn/authlogTo have commit access your user needs to have write priviledges to the subversion repository (which is true in this simple case since you own the repository).