Knowledge Base

How to configure Subversion (SVN)

This article demonstrates how to configure Subversion (also known as SVN). This involves setting up repositories on the server, and configuring clients to access them.

About Subversion

Subversion, also known as SVN, is a replacement for the Concurrent Versions System (CVS). Like all version control systems, Subversion enables you to track multiple revisions of files and directories. It is installed on all A2 Hosting shared servers.

This article only discusses configuring Subversion on an A2 Hosting account. It does not explain all of the features or how to use Subversion. See the More Information section below for links about how to use Subversion.

Creating a repository

To create an SVN repository, all you have to do is log in to your A2 Hosting account using SSH, and then type the following command:

svnadmin create /home/USERNAME/REPOSITORY

Replace USERNAME with your A2 Hosting account username, and replace REPOSITORY with the name of the directory where you want to create the repository (if the directory does not already exist, the svnadmin create command creates it).

Selecting an authentication method

To access SVN repositories on an A2 Hosting server from another computer, you must use an SVN client that supports SSH (Secure Shell). HTTP and HTTPS connections are not supported.

SSH supports several authentication methods, including passwords and public-key authentication. Every time an SVN client connects to a repository, it must authenticate using SSH. To avoid the hassle of typing a password over and over, you can:

  • Use a SSH password caching tool, such as ssh-agent on a Unix-like system, or Pageant on a Microsoft Windows system.
  • Generate a key pair and use public-key authentication.

This article assumes that you will use public-key authentication with SSH and SVN.

Configuring an SVN client

You know how to create an SVN repository, but right now you can only check out and import files directly on the server. Clearly, you will want to set up an SVN client so you can work with repositories from another computer.

Configuring an SVN client to work with repositories is a three-step process:

  1. Generate a key pair for SSH public-key authentication, and then deploy the public key to the A2 Hosting server.
  2. Configure the SSH client to connect to the A2 Hosting server using the private key.
  3. Configure the SVN client.

The exact steps to do this depend on the client computer's operating system. Follow the appropriate procedures below for your computer's operating system.

Microsoft Windows

Follow these procedures to set up an SVN client if the computer is running a Microsoft Windows operating system.

Step 1: Generating a key pair
Step 2: Configuring the SSH client to connect to the A2 Hosting server

To complete steps 1 and 2, follow the step-by-step procedures described in this article. After you complete these procedures, you will have a fully-functioning SSH client installation that authenticates to the A2 Hosting server using keys. You do not have to type a password to access your account on the server.

  • These procedures instruct you to install PuTTY, a popular SSH client for the Microsoft Windows operating system. PuTTY is the default SSH handler used by the popular TortoiseSVN client.
  • When you generate a key pair, we recommend that you do not specify a passphrase. The TortoiseSVN client connects to the server many times during a session. If you have a passphrase-protected key pair, you must retype the password every time the client connects to the server.
Step 3: Configuring the SVN client

TortoiseSVN is a popular client for managing SVN projects. The following procedure describes how to set up TortoiseSVN to access repositories on an A2 Hosting server.

By default, TortoiseSVN uses PuTTY to handle SSH connections. During installation, TortoiseSVN registers itself as a handler for the svn+ssh protocol, and calls an application named TortoisePlink (which is a modified version of PuTTY) to handle the SSH connection. TortoisePlink uses the profile and session settings you create in PuTTY. This entire process is normally invisible to users.

To set up the TortoiseSVN client, follow these steps:

  1. Download and install the TortoiseSVN client. You can download TortoiseSVN at http://tortoisesvn.net/downloads.html.
  2. Start the TortoiseSVN Repository Browser. To do this, right-click on the desktop or on a folder, click TortoiseSVN, and then click Repo-browser. The URL dialog appears.
  3. In the URL text box, type the URL to your repository. The URL should be in the following format:
    svn+ssh://PROFILE/home/USERNAME/REPOSITORY
    Replace PROFILE with the name of the session profile that you saved in PuTTY when you set up the keys, replace USERNAME with your A2 Hosting account username, and replace REPOSITORY with the path to your SVN repository on the server.
  4. Click OK. If the connection succeeds, after a few seconds the Repository Browser displays the repository files. You can expand folders to view their contents, and browse different revisions as well. To view a complete list of options, right-click a repository folder in the Repository Browser.
Mac OS X and Linux

Follow these procedures to set up an SVN client if the computer is running Mac OS X or a Linux-based operating system.

Step 1: Generating a key pair
Step 2: Configuring the SSH client to connect to the A2 Hosting server

To complete steps 1 and 2, follow the step-by-step procedures described in this article. After you complete these procedures, you will have a fully-functioning SSH client installation that authenticates to the A2 Hosting server using keys. You do not have to type a password to access your account on the server.

When you generate a key pair, we recommend that you do not specify a passphrase. If you have a passphrase-protected key pair, you must retype the password every time the client connects to the server.
Step 3: Configuring the SVN client

The svn command line client is often the quickest and easiest way to interact with SVN, although there are GUI-based clients as well. In either case, however, clients use SSH to access SVN. For security reasons, A2 Hosting uses custom port 7822 for SSH connections instead of the default port 22. Therefore, whichever Subversion client you use, you must configure it to use port 7822 for SSH.

The easiest way to do this is to create a custom protocol for Subversion that is only used for A2 Hosting servers. This allows you to still use the regular svn+ssh protocol for other servers that use standard port 22 for SSH.

To create a custom SSH protocol for Subversion, follow these steps:

  1. On the client computer, open the ~/.subversion/config file in a text editor.
  2. Locate the [tunnels] section, and then add the following line of text:
    a2hosting = ssh -p 7822 -q
  3. Save the changes and exit the text editor.
  4. You can now use the custom protocol svn+a2hosting:// to access a SVN repository over SSH. For example, the following command demonstrates how to check out files from a repository on an A2 Hosting server to your client computer. Replace both instances of USERNAME with your A2 Hosting account username, example.com with your domain name, and REPOSITORY with the path to the repository:

    svn co svn+a2hosting:[email protected]/home/USERNAME/REPOSITORY

More Information