Setting up my own SVN server

SVN comes pre-installed on one 1and1 hosting, but 1and1 does not run the server or apache module, so you are forced to access it using svn+ssh mode.

Edit: 1and1 complained at me for doing this, which prompting my move to slicehost, where I am much happier.

Edit2: You might also want to know how to set up passwordless SSH for *nix

I wanted to use it to version control for a set of scripts which are live on the server. My process went like this:

svnadmin create repo/
mv repo/hooks/post-commit.tpl repo/hooks/post-commit
chmod +x repo/hooks/post-commit
svn checkout file:///[absolute path to repo] [live dir]

Then I modified post-commit to include the following:
cd [absolute path to live dir]
/usr/bin/svn update

Now whenever I commit anything to the repository, it updates the live directory with a fresh copy from the version control system. I can manually change non-versioned files in the live directory, but if I change a versioned file, it will stay static unless I delete it or manually check it in.

I also set up TortoiseSVN (a windows svn shell extension) to my liking. One aspect of this included getting it to cache passwords. The quick version is as follows.

  • On the server:
    • ssh-keygen -t rsa -f server.ppk
    • if it does not exist, create a .ssh directory in the home directory
    • cat server.ppk.pub >> ~/.ssh/authorized_keys
  • Get putty.exe and puttygen.exe
  • Copy server.ppk from the server to the windows machine
  • Run puttygen.exe, click “Load” and locate server.ppk
  • Add a comment if you like, then click “Generate” and save it
  • Fire up putty, enter your server url, then browse to:
    • Connection->Data and enter your Auto-login username
    • Connection-SSH->Auth and browse to the private key generated by puttygen
    • Go back to Session, enter a name for “Saved Sessions”, and click “Save”
  • Now, when you use TortoiseSVN, you can use this name in place of the server with no username or password, like this:
    svn+ssh://SavedName/[absolute path to repo]

Post a Comment

Your email is never published nor shared. Required fields are marked *