Secure Subversion Setup(Centos + Apache + SSL)


Secure subversion setup (Centos 5.6+Apache+SSL)

Subversion is an open source version control for any type of programming. For ex. in software development, versioning is most important. Versioning is most recommended in web development.

Subversion can keep maximum of 232 – 1 versions in 32-bit operating system. For 64-bit it’s infinite.
Subversion can serve files in two methods; one is through SVN daemon – which run SVN as a service, second is running SVN with apache – which run as application.
Setting up SVN daemon is very easy compare to run with apache.
1.       Install SVN as a daemon.
 yum install subversion
#second step is to create SVN repository,
svnadmin create /var/www/svnrepo
cd /var/www/svnrepo


#edit configuration file in svnrepo
nano conf/ svnserve.conf
#find the below lines and uncomment or add these lines,
anon-access = none
auth-access = write
password-db = passwd
#save the file

#next edit the file called passwd, which contain users who authorized to access SVN repository
nano /conf/passwd
#add users and password under [users] directive
#save and close.


Import project into SVN repository
svn import /tmp/myproject/ file:///var/www/svnrepo/test
#location of /tmp/project/ must be present before import. /tmp/project/ can contain source code files are any file to track record of versions.

Start the daemon,
svnserve -d
Open any SVN client (Tortoise SVN) and type svn://serverip/svnrepo/test or type svn://serverip/svnrepo/test in any browser (SVN client must be installed on PC), it will show the files in the repository. Once repository opened, right click in the repo name and find more options.
  
2.       Install SVN in centos with apache

user@localhost# yum install subversion mod_dav_svn
user@localhost# cd /var/www/
user@localhost# mkdir svn
user@localhost# cd svn

Create SVN repository
user@localhost# svnadmin create svnrepos
user@localhost# chmod  -R g+ws  svnrepos/
user@localhost# chgrp  -R apache svnrepos/
user@localhost# 


Create authentication file for apache users, users in this can only able to access SVN repository
user@localhost# htpasswd –cm /etc/svn-auth-conf  <username>
# this command will create a single user in /etc/svn-auth-conf file. To add more users type,
user@localhost# htpasswd –m /etc/svn-auth-conf  <username>

Edit subversion.conf in /etc/httpd/conf.d/subversion.conf, this is the config file for SVN.
user@localhost# nano /etc/httpd/conf.d/subversion.conf
#uncomments the following or add new,

#SSL certificate location
SSLCertificateFile /etc/pki/tls/certs/public.key
SSLCertificateKeyFile /etc/pki/tls/private/private.pem
<Location /svnrepos>
   DAV svn
   SVNPath /var/www/svn/svnrepos
   <LimitExcept GET PROPFIND OPTIONS REPORT>
      SSLRequireSSL
      AuthType Basic
      AuthName "Authorization Realm"
      AuthUserFile /etc/svn-auth-conf
      Require valid-user
   </LimitExcept>
</Location>
#save and close the file
Import project into SVN repository
svn import /tmp/myproject/ file:///var/www/svnrepos/test
#location of /tmp/project/ must be present before import. /tmp/project/ can contain source code files are any file to track record of versions.
Finally restart apache server,
/etc/init.d/httpd restart
SVN repository can only be accessible with https instead of http.
Open any SVN client and type
Enter the username and password to connect. More options are available once project checked out from repository. Right click the repository and find out more
Multiple Repository setup
/etc/httpd/conf.d/subversion.conf
<Location /WEB>
   DAV svn
   SVNListParentPath on
   SVNParentPath /var/www/wsvn/repos/WEB
</Location>

<Location /DEV>
   DAV svn
   SVNListParentPath on
   SVNParentPath /var/www/wsvn/repos/DEV
</Location>

Download As PDF

No comments:

Post a Comment