Set up Subversion with SSH (svn+ssh)

=Setup SVN Server=

  1. Install Subversion
    • Red Hat/CentOS/Fedora
    • {{{ lang=bash
      sudo yum install subversion

    • Debian Based (Ubuntu)
    • {{{ lang=bash
      sudo apt-get install subversion

  2. Create a repository
  3. {{{ lang=bash
    sudo mkdir /data01/svn
    sudo mkdir /data01/svn/repos
    sudo svnadmin create /data01/svn/repos/new_repo

  4. Create an SVN group (add whichever users you would like to it)
  5. {{{ lang=bash
    sudo groupadd svn
    sudo usermod -a -G svn svn_user

  6. Create svn user as part of the svn group.
  7. {{{ lang=bash
    sudo useradd -g svn svn

  8. Give the new group ownership of the repos directory and set the permissions.
  9. {{{ lang=bash
    sudo chown -R svn:svn /data01/svn
    sudo chmod -R 775 /data01/svn

  10. Create a wrapper for [[|svnserve]] at `/data01/svn/`.
  11. {{{ lang=bash
    # set the umask so that files are group writable
    umask 002
    # call svnserve, passing the default repo location
    exec /usr/bin/svnserve “$@” -r /data01/svn/repos

  12. Symlink to `/usr/local/bin`. Set permissions appropriately.
  13. {{{ lang=bash
    cd /usr/local/bin/
    sudo ln -s /data01/svn/ svnserve
    sudo chmod 755 /data01/svn/

=Setup Key-Based Authentication=

  1. Create public/private key pair using ssh-keygen on local machine.
  2. {{{ lang=bash
    svn@cwch3wnsapvl001:/home/svn$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/data01/home/svn/.ssh/id_rsa):
    Created directory ‘/data01/home/svn/.ssh’.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /data01/home/svn/.ssh/id_rsa.
    Your public key has been saved in /data01/home/svn/.ssh/
    The key fingerprint is:

  3. Copy the public key to remote host with ssh-copy-id
  4. {{{ lang=bash
    ssh-copy-id -i ~/.ssh/ user@remote-host

  5. Test login from remote-host. Verify that it is now passwordless
  6. {{{ lang=bash
    user@localhost:~$ ssh





Leave a Reply

Your email address will not be published. Required fields are marked *