Stealth subversion install - access over SSH...

Want to use SubVersion but only have access to a box via SSH? Maybe you've got a cheap web hosting account and the host hasn't gotten with the program to officially offer SubVersion as a feature?

This post outlines a way to install SubVersion server and have your client access the repositories via SSH.

Pros:

  • If you've got SSH access and rights to compile some code, you can get SubVersion running. I was able to do this on a cheap Bluehost.com account.
  • You can access your repository from anywhere. You don't have to rely on being connected to local filesystems or a WebDAV enabled server.
  • SubVersion is a rocking version control system.

Cons:

  • Your checkins will be tagged with the user account of the SSH user. Most web hosts only give you 1 SSH login. This can be not so great if you have multiple developers but just 1 login.
  • Client access can be trickier than local file access or WebDav access.
  • You may have to set up a SSH tunnel manually depending on what client you use.
  • The url you have to use is a pain to remember.
  • Performance, this is not the optimal scaling solution for a SubVersion installation.

How it works:
Basically you are setting up a trim SubVersion install that will run svnserve on demand. When you connect with your client using "svn+ssh" , sshd will launch svnserve to complete your requests and then shut it back down.

How to set it up:

1 ) Login and make a directory to hold files while we build the project:

mkdir ~/src

2 ) Install APR

cd ~/src
wget http://www.mirrorgeek.com/apache.org/apr/apr-0.9.16.tar.gz
tar -xzf apr-0.9.16.tar.gz
cd apr-0.9.16
./configure --prefix=$HOME
make
make install

3 ) Install APR-Util

cd ~/src
wget http://www.mirrorgeek.com/apache.org/apr/apr-util-0.9.15.tar.gz
tar -xzf apr-util-0.9.15.tar.gz
cd apr-util-0.9.15
./configure --prefix=$HOME --with-apr=$HOME
make
make install

4 ) Get and make Subversion

cd ~/src
wget http://subversion.tigris.org/downloads/subversion-1.4.5.tar.gz
tar -xzf subversion-1.4.5.tar.gz
cd subversion-1.4.5
./configure --prefix=$HOME --without-berkeley-db --with-zlib --with-ssl
# at this point there's a bit of complaining about berkeley db, let's ignore that...
make
make install

5 ) Test it!

cd ~
svn --version
svnadmin --version

6 ) Create a repository

cd ~
mkdir svn
cd svn
mkdir test

svnadmin create /home/[user]/svn/test

7 ) Update path

You may need to update your path (like in .bashrc) to make sure the /home/[user]/bin directory is included. This will be required so sshd can find the Subversion binaries.

8 ) Login via svn+ssh

From here on out you can use SubVersion with your favorite client. Right now my favorite Windows client is Tortoise. Its got built in support for PLINK so you don't have to do any fancy tunneling junk manually.

If you use a different client you may have to do some VPN tunneling magic. There is an article that covers that here and here. Just remember if you're working on Windows, putty is your friend (along with its related utilities like plink).

Import some code into your test repository, then check it out. The url you will use needs to look like this (replace the items in square brackets with values for your setup):

svn+ssh://[user]@[domain.com]/home/[user]/svn/test

-- Dave

Add new comment