Connecting to a Subversion Repository
From Ece
Contents |
Repository URLs
In order to connect to a Subversion repository, you must first tell your Subversion client how to reach the repository by providing a URL. A full URL has the form:
protocol://user@hostname/path/to/repository/path/in/repository/
Protocol
There are a few available methods that a remote server may support for accessing subversion repositories, and the protocol portion of the URL tells Subversion which method to attempt to use.
- Subversion can run as an Apache web server module, to be accessed over HTTP, with the option of SSL encryption. The corresponding protocol is
httporhttps://if SSL is used. - Subversion's custom server can be run as a standalone service. The corresponding protocol is
svn. - The Subversion client can establish an SSH connection and invoke
svnserveon the server in tunnel mode. This is the method supported on Yavin, and the corresponding protocol issvn+ssh.
Thus, for repositories on Yavin, your repository URL will begin with:
svn+ssh://
User Name
Subversion must know the user name that you use to log in to the remote server. Unless you are currently logged in to Windows or Linux with the exact same user name as you use on the remote server, you must include the user@ portion of the URL.
If connecting to a repository on Yavin, your URL will begin as follows (replace username with your own user name on Yavin):
svn+ssh://username@
Also note that if you are using shared access, you must specify the username of the user who owns the repository and has set up their account to let you connect to the repository. For example, if jdoe is sharing a repository with jschmoe via the remote command:
command="svnserve -t -r /home/jdoe/svn/reposparent/ --tunnel-user=jschmoe"
then jschmoe connects as jdoe.
svn+ssh://jdoe@
Host Name
The host name is a unique name for the server on which your repository resides. If you are connecting to Yavin, you could use the host name yavin.ece.msstate.edu, although an alternate/alias host name for Yavin is svn.ece.msstate.edu. That expands the URL to a Yavin-hosted repository to:
svn+ssh://username@svn.ece.msstate.edu
Path
The final part of the URL is the file path. While it may not be obvious, the path actually contains two different paths—the path to the repository, and the path inside the repository.
Path to Repository
The first part of the path describes where the repository is located on the server. For a typical setup, the root / in the URL corresponds to the root / on the server.
For example, if jdoe has a repository directory named repos in his home directory, the path to this repository would be:
/home/jdoe/repos
The URL should also specify this path on the server. In jdoe's case:
svn+ssh://jdoe@svn.ece.msstate.edu/home/jdoe/repos
However, there is an important exception! If you are connecting to the remote server via shared access, the root / in the URL does not necessarily correspond to / on the server anymore. If the remote command uses the -r <ReposRoothPath> option, then root / in the URL corresponds to <ReposRootPath>.
Note: If you are using shared access but did not set up the repository, then just ask the person who did set it up for the correct path to the repository.
As an example, if the remote command was specified as
command="svnserver -t -r /home/jdoe/svn/reposparent --tunnel-user=jschmoe"
and the repository directory is /home/jdoe/svn/reposparent/repos/, then jschmoe will connect to the repository with the following URL:
svn+ssh://jdoe@svn.ece.msstate.edu/repos
Path Inside Repository
If you were to look at the actual file system and browse the contents of your repository directory, you will not simply see the contents of your repository. Instead, you will see the file system Subversion uses to represent the contents of your repository.
In the repository URL, however, the rest of the path (after the path to the repository) is actually a virtual path corresponding to your versioned directory tree. If, for example, you have a project myproj in the root of the repository, and you want to checkout the subdirectory trunk, then the virtual path is /myproj/trunk. If you want to checkout the entire repository, the virtual path is just / (which is optional in the URL).
For example, for jdoe's private repository at /home/jdoe/repos, the URL for the trunk of myproj is:
svn+ssh://jdoe@svn.ece.msstate.edu/home/jdoe/repos/myproj/trunk
Or to simply access the root of the repository, the URL could be specified as either of these:
svn+ssh://jdoe@svn.ece.msstate.edu/home/jdoe/repos svn+ssh://jdoe@svn.ece.msstate.edu/home/jdoe/repos/
Connecting from Windows
The following covers some specifics about connecting to a repository from a Windows system, likely with the command-line client or with TortoiseSVN. You will need an SSH client to connect. PuTTY is the recommended choice.
Using a Saved PuTTY Session
A repository URL can be shortened slightly by using a saved session in PuTTY.
If you specify just the host name in the session SvnConn (or some other preferred name), the URL can be shortened to:
svn+ssh://username@SvnConn/path/to/repository/path/in/repository
You can specify the user name in your session as well, and shorten the URL to:
svn+ssh://SvnConn/path/to/repository/path/in/repository
Authenticating with Pageant
At this time, it appears that both TortoiseSVN 1.5 and the command-line Subversion 1.5 client can only be connected via public-key authentication with Pageant.
Connecting the Command-Line Client via Plink
In order for the command-line Subversion client to connect over SSH, a command-line SSH program such as PuTTY's Plink must be installed.
And, in order for Subversion to find Plink in order to connect, you must set a Windows environment variable, SVN_SSH:
- Open Control Panel (Start → Control Panel)
- If you are in Category View, select Performance and Maintenance, followed by System. If you are in Classic View, double-click System.
- Choose the Advanced tab.
- Click the Environment Variables button.
- You will see two lists of variables. The top is User variables (i.e. those specific to your user account). If you are the only user of your computer, you'll want to add a User variable. If you want the setup to work for multiple accounts, you'll want to define a System variable.
- Under the desired variable list, click the New button.
- For the Variable name field, enter
SVN_SSH. - For the Variable value field, enter the path to Plink, entering backslashes (\) as double backslashes (\\). For example:
C:\\Program Files\\PuTTY\\plink.exe
- Click OK to add the variable, OK again to save your changes to environment variables, and OK once more to close the System Properties dialog.
Note that Pageant is still required in order for Plink to establish the connection in the background.
Shared Access using PuTTY
A restrictive form of public-key authentication involves restricting a public-key access for a given key, such that only a single command can be run by the person using that key. For Subversion, this is mainly useful for granting access to your repository to certain other users. Details about this setup can be found here.
If someone is granting you access to a repository this way, you will need to:
- Give them a public key for which you have the matching private key
- Use their username in the URL to their repository
- Ask them for the correct path to the repository
If you are the person granting access to a repository in this way, you will need to be careful about how you manage your keys. The simplest approach is to simply keep your public key in the authorized_keys unrestricted. If, for some reason, you want to restrict your key to the svnserve command, realize that you will need separate key-pairs for Subversion and interactive logins. Additionally, if you want both Subversion and your interactive logins to use Pageant, you will have to be careful to restrict each use to the proper key, as follows:
- Create two saved sessions in PuTTY, one for Subversion, and one for interactive logins.
- Set each session to use its specific private key.
- Load both keys into Pageant.
This configuration will ensure that each saved session cannot use just any key in Pageant; it may only use the one which you have specified.
Connecting from Linux/UNIX
The following covers some specifics about connecting to a repository from a Linux or UNIX system with the Subversion command-line client. You will need an SSH client to connect to Yavin; you probably already have OpenSSH installed.
Authenticating With a Password
If OpenSSH is installed, you should be able to connect already. When Subversion needs to access the repository, you will be prompted for your password to the remote server. This is easy from a configuration standpoint, but the repetitive password prompts can be frustrating.
Public-Key Authentication
You can set up public-key authentication and store your private key in an authentication agent to automate Subversion connections. Generate a key pair with ssh-keygen and then use ssh-agent to store your decrypted private key.
(More on this eventually, in an OpenSSH article.)
Shared Access using OpenSSH
(This is actually just an unverified hunch, for now.)
See corresponding section for Windows first. If, for some reason, you want to restrict your key to svnserve, and you intend to use ssh-agent, then you need to make sure Subversion is not allowed to use just any key in ssh-agent. To restrict which key is used, you will need to add the following to your .bashrc:
export $SVN_SSH = "ssh -i ~/.ssh/svn_key_name"
See Also
- Subversion
- Subversion Repository Administration
- Subversion Basic Use
- Subversion Branches and Tags
- TortoiseSVN
- OpenSSH
- PuTTY
External Links
- Subversion (official Web site)
- Version Control with Subversion is the official (online) Subversion book.




