HOWTO: Accessing a Subversion repository over SSH

apps

#1

I was interested in creating a private subversion repository on my web server,
and inquired with support into running a server process on the server so that
I could access the repository remotely. Since support confirmed that I would
be unable to do this, I managed to get it working over SSH, and figured I’d
share it with everyone, since I did see that there were a few entries on the
suggestion panel for subversion support.

Note that I am using the TortoiseSVN Windows client for accessing the repository…
Doing it in *nix or from the svn command line client is an exercise left for
the reader.

  1. Compile subversion:
  • Download the latest tarball from subversion.tigris.org
  • Untar into your home directory
  • cd
  • ./configure (you will get a warning that berkeley db is not supported - this
    is fine, you’ll use fsfs)
  • make
  1. If everything compiled correctly (I had no problems on guilder.dreamhost.com),
    copy the binaries to your home directory:
  • cp \subversion\svnserve\svnserve
  • cp \subversion\svnadmin\svnadmin
  1. Create the root repository:
  • mkdir repos
  • svnadmin --fs-type fsfs repos

3.5. Fix your SSH path:

  • Add the following to ~/.bashrc and ~/.bash_profile:
    export PATH=$PATH:/home/
  1. Download latest TortoiseSVN from tortoisesvn.tigris.org and install on your
    Windows client.

  2. Configure TortoiseSVN for your subversion repository:

  • Right click on something (desktop, whatever)
  • Go to TortoiseSVN -> Settings
  • Go to the Network tab
  • In the SSH client box, enter the following:
    C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe -l -pw
    (note that you can omit the password for security reasons, but you will then
    be prompted to enter your password every time a request is made, which gets
    annoying, quickly, since your password is not cached)
  • Hit OK to save
  1. Attempt to browse to your repository:
  • Right click on something
  • Go to TortoiseSVN -> Repo-Browser
  • Enter the following URL:
    svn ssh:///home//repos
  • Hit OK and attempt to expand the repos directory (click the plus)
  • If you get no errors, you’re in

Notes:

  • Obviously, you may not want to share your ssh login/password with other people
    that you want to give subversion access. I believe you can make another account
    from the admin panel for subversion access - you should be able to give it
    permission to your repos directory and copy the binaries there. Again, this is
    an exercise left to the reader.
  • This is not the fastest/most efficient way to do subversion - every request
    must do the following:
  • Open an SSH session.
  • Invoke the svnserve process.
  • Communicate with the svnserve process.
  • Kill the svnserve process and close the SSH session.
    Yes, it’s going to be slow. But it will work, and large commits/imports/exports
    are not as affected, since once the connection’s open and the server process
    is started, the speed will depend on your connection to the server. It’s just
    the initialization/clean up that adds a few seconds of overhead to each request.
  • For the Dreamhost admin’s peace of mind, the svnserve process is invoked with
    a command line switch that indicates it’s being used through an SSH tunnel and
    communicating through stdin/stdout. It never listens on a TCP port.

Let me know if you have any questions. A word of caution: I’m only beginning to
use subversion/TortoiseSVN, so I probably won’t be too much help outside of
clarifying the above. =)

EDIT: Forgot about the path setting (3.5) - this is necessary so that svnserve can be found by the SSH shell…