Monday, August 23, 2010

Subversion with SSL


I have recently installed SVN to my system, and configured it with SSL. Adding it here might help me further or other people can get helped.

1. Install apache(httpd)
            sudo ./configure --prefix=/opt/vivek/apache --enable-dav --enable-so --enable-ssl
            ## if this gives you error like "configure: error: ...No recognized SSL/TLS toolkit detected" then install
            ## apt-get install openssl libssl-dev
            sudo make
            sudo make install

2. Install dependency for subversion (check dependency using sh ./autogen.sh)

            1. Install sqlite
            2. Get the sqlite 3.6.13 amalgamation from:
                        http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz
                        Unpack the archive using tar/gunzip and copy sqlite3.c from the
                        Resulting directory to:
                        /home/vivek/Desktop/TGZS/subversion-1.6.12/sqlite-amalgamation/sqlite3.c
                        This file also ships as part of the subversion-deps distribution.
            3. You need autoconf version 2.50 or newer installed (i used synaptic)
            4. You need libtool version 1.4 or newer installed

3. Install subversion now.
            sudo ./configure --prefix=/opt/vivek/subversion --with-apxs=/opt/vivek/apache/bin/apxs --with-apr=/opt/vivek/apache/bin/apr-1-config --with-apr-util=/opt/vivek/apache/bin/apu-1-config  --with-ssl
            sudo make
            sudo make install

4. after Installation
            groupadd svn
            useradd -m -d /srv/svn/ -g svn svn
            After adding user i go to user and groups and make the user enable(add password 123456)

5.
            su - svn (give password of svn user - 123456)
            $ mkdir /srv/svn/repositories/
            $ mkdir /srv/svn/repositories/myproduct
            $ mkdir /srv/svn/conf
            $ /opt/vivek/subversion/bin/svnadmin create /srv/svn/repositories/myproduct


6. Add following to apache/conf/httpd.conf, for http access to users
            <Location /repos>
            DAV svn
            SVNParentPath /srv/svn/repositories
            # our access control policy
            AuthzSVNAccessFile /srv/svn/conf/users-access-file
            # try anonymous access first, resort to real
            # Authentication if necessary.
            Satisfy Any
            Require valid-user
            # how to authenticate a user
            AuthType Basic
            AuthName "Subversion repository"
            AuthUserFile /srv/svn/conf/passwd
            </Location>

            CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION

            That file, /srv/svn/conf/passwd, can be created using apache/bin/htpasswd:
            htpasswd -m -c /srv/svn/conf/passwd vivek (use htpasswd --help first for options)
            it will prompt you to password for vivek

            ** This way you can add user for http access.

            Add following to /srv/svn/conf/users-access-file to set permission for user.
            [/]
            * =
            [myproduct:/]
            vivek1 = rw
            vivek2 = r

            run svnserve for required location
            /opt/vivek/subversion/bin/svnserve -d -r /srv/svn/repositories/myproduct

7. Now access url http://localhost/repos/myproduct,


8. Add project as
            sudo /opt/vivek/subversion/bin/svn import myproduct file:///srv/svn/repositories/myproduct -m "added project"
            /opt/vivek/subversion/bin/svn ls svn://localhost/myproduct


9. You can add permission to myproduct folder by changing /srv/svn/repositories/myproduct/conf/passwd and svnserve.conf file.

    Add following to svnserve.conf
                        [general]
                        anon-access = read
                        auth-access = write
                        password-db = passwd
                        authz-db = authz
                        # realm = My First Repository
                        [sasl]
                        use-sasl = true


   Add following to /srv/svn/repositories/myproduct/conf/authz

                        [groups]
                        group1 = vivek1
                        group2 = vivek2

                        [/]
                        vivek = rw
                        *=

                        [myproduct:/]
                        @group1 = rw
                        [myproduct:/]
                        @group2 = r    ## this wont allow user to do svn co or commit

10. If you want to disable credential caching permanently, you can edit your runtime config file (located in /home/vivek/.subversion/config).

                        [auth]
                        store-auth-creds = no

Thanks to http://queens.db.toronto.edu/~nilesh/linux/subversion-howto/

No comments: