Site5 - Built For Designers & Developers MENU
Home  ›  Programming Tools  ›  SVN/Subversion (SVN) Setup Guide

SVN/Subversion (SVN) Setup Guide

17 Comments

Creating a New SVN Repository

If you have not already done so, this section will show you how to create a fresh SVN repository and how to setup the initial directory structure (trunk/branches/tags).

First, create a private folder (outside of public_html or www):

cd ~
mkdir svn

Create the repository:

svnadmin create /home/[site5-username]/svn/[projectx]

Note: The SVN folder will be where we store all of our projects, this differs from the .svn folders (which holds metadata about the files in your project).

Optional (but recommended) setup the initial SVN structure

cd ~/svn
mkdir tmpdir
cd tmpdir
mkdir trunk
mkdir branches
mkdir tags

svn import . file:///home/[site5-username]/svn/[projectx] --message 'Initial repository structure'

The output will look like this:

Adding         trunk
Adding         branches
Adding         tags

Committed revision 1.

Now go back and remove the “tmpdir” as it is no longer needed:

cd ..
rm -rf tmpdir

You can verify the results of the import by running the svn list command:

svn list --verbose file:///home/[site5-username]/svn/[projectx]

The output will look like this (where site5-username is your actual account username):

      1 site5-username               Dec 30 09:42 ./
      1 site5-username               Dec 30 09:42 branches/
      1 site5-username               Dec 30 09:42 tags/
      1 site5-username               Dec 30 09:42 trunk/

Bash Shell Fix

There is a line (mesg y) inside the global bashrc file that will cause repeated messages when interacting with SVN (stdin: is not a tty). To get rid of this message, you need to make a small modification to your bashrc file. Once logged in via SSH, do the following:

cp /etc/bashrc ~/.bashrc
nano ~/.bashrc

Press Ctrl+W and search for mesg, if you find it comment out the line “mesg y” — it should say “# mesg y”
Press Ctrl+X to exit and press Y when prompted to save.

Setup a new SVN user account

Create an authorized keys file for storing the logins in

cd ~
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

Configure authorization

First we need to generate RSA key pair (this should be done locally on your workstation):

ssh-keygen -t rsa

Accept the default file name, the password can be left blank (but if you’re feeling paranoid a password can be entered). By default it will create two files called id_rsa (the private key that should be downloaded and only be kept on your computer) and id_rsa.pub (the public key which we will use in the next step).

Note: This will create an RSA key for use in SSH protocol 2 connections, the server(s) have had the protocol version 1 disabled so you will want to ensure that your client is using version 2 as well. Otherwise you may receive an error such as “Connection closed unexpectedly.” when trying to initially connect.

Using nano or an FTP client open up ~/.ssh/authorized_keys and enter the following (all on one line):

command="/usr/bin/svnserve -t -r /home/[site5-username]/svn",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty [public key text from id_rsa.pub]

Make sure that you change [site5-username] and [public key text from id_rsa.pub].

Note: If you get an error message like svn: URL ‘svn+ssh://[url]’ non-existent in that revision you should remove the -r /home/[site5-username]/svn from the configuration outlined above.

(Before you do that though, note that svnserve’s ‘-r’ option changes the root of the filesystem as seen by the client, and therefore the URL that they use to log in should also change. E.g. in the example above, their path will begin after [projectx]. If they’re trying to log in using the full path to the repository, they will see the error above.)

Note: The command must be entered exactly as given above. If you follow all of the instructions in this document and you are being asked for a password when you try to log in from your subversion client, ensure that there are no spaces between the commas in the command.

Note: This will allow the user to SSH to your account with their private key, but will give them no access to your server and will only allow SVN activity on that specific repository. Also make sure that you have deleted id_rsa and id_rsa.pub from your server.

If you want to have multiple svn users for this account, then the command in ~/.ssh/authorized_keys should also have the –tunnel-user=<svn username> option given. <svn username> is NOT the site5 username; it is the name you wish the user’s checkins & checkouts to show up under.

Additionally, each svn user will need to provide a separate public key to the administrator; there will be one line per user in authorized_keys using the format already given in the instructions, substituting the public key with the correct public key given by each svn user.

Desktop Integration

Eclipse

Eclipse is a cross-platform integrated/project development environment and supports SVN integration to use your newly created SVN repository open Eclipse and click:

  • File -> Import -> SVN -> Project from SVN (note if this option is not available click Help -> Software Updates -> Manage Configuration and find Subversive and install)
  • Create new repository location
  • URL: svn+ssh://[site5-username]@www.[domain.com]
  • Leave username and password blank
  • Select SSH Settings tab
  • Select Private key and browse for id-rsa and select it, enter the password (if you set one)
  • Press Next (if you get a provide authentication information dialogue press Ok)
  • Select the trunk folder and press Finish
  • Follow the Add new Project wizard to finish checking out your SVN repository

Note: right click the project and press Team -> Synchronize with Repository to commit any changes back to your SVN.

TortoiseSVN via PuTTY

TortoiseSVN is a Microsoft Windows only shell extension that integrates SVN with Explorer and it can be used in conjunction with PuTTY to connect to your SVN repository. Once installed:

  • Open PuTTYgen load your private key (e.g. id-rsa)
  • Press Save private key, once saved close PuTTYgen
  • Open PuTTY and enter your domain name in the Host Name (e.g. domain.com)
  • Under Connection -> SSH -> Auth select your Private key (you just generated with PuTTYgen)
  • Under Connection -> Data enter your Site5 username in the auto-login username
  • Go back to Session and in Saved Sessions enter a name (e.g. domain) and press Save

Go to your documents:

  • Create a new folder
  • Right click TortoiseSVN -> Settings -> Network -> in SSH client enter: C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe press Ok
  • Right click SVN Checkout…
  • URL: svn+ssh://[email protected]/home/username/path/to/svn/repo
  • Press Ok and if you set a password you will prompted for it before it checks out

SVN client on the command line

The official SVN command line client can also be used to connect and perform all the same actions as the above clients (see: SVN Quick Reference Card). On Linux and Mac systems the SVN client normally comes preinstalled, Windows users can install the command line client from: http://www.collab.net/downloads/subversion/. Once installed:

  • Open the SVN client config file (on Linux/Mac systems this is normally: ~/.subversion/config)
  • Under the [tunnels] section add: site5 = /usr/bin/ssh -p 22 -q -l [site5-username] -i [/full/path/to/your/private/key]
  • Save the file and checkout your repository via: svn co svn+ssh://username@[domain.com]/[projectx]

Still have a question? Or need help?
If you need technical support with your account, please email us or chat live with a representative.

17 Comments

  • is there any easy version of this, script or something. I want to browse svn with tortoisseSVN on windows with permission to do check in and check out. So far nothing worked.

  • Just a quick note, make sure you get bash shell enabled, just submit a request and it takes like 5 minutes, otherwise some of these steps won’t work.

  • I was following this article to get SVN+SSH working on my account, and it worked perfectly.

    However, there is an error in the TortoiseSVN part of the article. Firstly, if you have set “-r /home/[site5-username]/svn” in the command in your authorized_users file, your URL will be svn+ssh://[email protected]/repo as the “-r” changes the root URL to your repository folder.

    Also, if you are using public key authentication in TortoiseSVN/PuTTY, your URL to access your repository should be:

    svn+ssh://[PuttySessionName]/home/username/path/to/svn/repo

    where [PuttySessionName] is the name of the session you saved in PuTTY with your primary key details. Using [email protected] will cause PuTTY to not use your primary key and keep prompting you for your server’s SSH password at every SVN operation.

  • To add to Andy’s comment above, if you are using PuTTY/TortoiseSVN, then I had to take two steps different from the article to get things to work correctly.

    1. Remove the -r /home/[site5-username]/svn portion of the line in the authorized_keys file

    2. Use the svn+ssh://[PuttySessionName]/home/username/path/to/svn/repo URL

    Until I did both things together, it just wouldn’t work no matter what different URLs I tried.

  • I got this to work but it seems like when I am using subversion to checkout the source, I am not able to SSH / SFTP into the server. Is this because I am already connected using the private key?

    • Hello,

      We do allow multiple SSH/SFTP connections from the same user/key. If you are still having issues with this, please open a ticket with our support department so we can look further into the problem for you.

  • Why don’t you just provide a panel tool to create and configure SVN repositories like some others web host companies do? It’s been a day I’m trying to follow this guide instructions without success :(

    • I am sorry to hear that you are having issues with the guide. If you are still having problems, please feel free to contact our support department directly so that they can better assist you. You can file a ticket through backstage, or by using one of the many contact methods found at the link below.

      http://www.site5.com/contact

      While an easy-to-use interface is a good idea, there is currently no plan to integrate one into our system at this time.

      • We are working on a way to access GIT repositories in a similar fashion as SVN (using Gitosis or Gitolite). A tutorial will be posted in this KB if and when we can solve that.

  • Hello
    I have a problem. I’m following all steps but only have a Fatal error : Server unespectedly closed network connection.

    Anyone can help me?? thank you so much!! :)

    • Hello Benet,

      Could you please contact our support department so they can try to narrow down the problem? You can open a ticket through backstage (http://backstage.site5.com) or by emailing [email protected].

      • Ok, John thank you! :)

  • FWIW, I had to change

    command=”/usr/bin/svnserve -t –r /home/[user]/svn…

    to

    command=”/usr/bin/svnserve -t –root=/home/[user]/svn

    before my system would start working correctly. Not sure why.

  • If you’re using TortoiseSVN and don’t apply the above bash shell fix, you’ll see something like the following

    —-
    Error Unable to connect to a repository at URL
    Error ‘svn+ssh://whatever/url’
    Error Network connection closed unexpectedly
    Completed!
    —-

    rather than the described ‘repeated messages when interacting with SVN’.

    This took me quite a while to figure out after a site5 server migration ‘broke’ TortoiseSVN; the new server’s /etc/bashrc had the offending ‘mesg y’ line, while the old server’s did not.

    (Also, overwriting your .bashrc with the global /etc/bashrc isn’t really making ‘a small modification to your bashrc file’, which would obviously lose any customizations you have.)

  • Am I the only MyEclipse/Subversive user whose ip gets banned too easily these days, even if using the same ssh certificate as always?

  • That is awfully complex – I haven’t been able to get it working. I imagine it’s because I’m missing a character somewhere. Even if I do get it working I’m not looking forward to explaining to the rest of the team how to generate their ssh keys.

    Is it possible to simply use ‘svnserve -d’ on Site5, and use svn: url’s to access our repos? I don’t particularly care about security these days. I haven’t been able to get that working either, and it would be nice to know if it’s because I’m making a mistake or if it simply can’t be done.

    • Hello Jamie,

      I am sorry to hear about the frustration you are having with our SVN article. We will be reviewing this article over the next few days to see if we can make it more straight forward and less complex.

      In regards to your questions about snvserve, it is unfortunately not available on our managed services.

      Because of the nature of the problem you are facing, we ask that you open a ticket with our support department so that we can assist you with your SVN setup.

      You can contact our support team by opening a ticket through Backstage.

      We look forward to hearing from you!

Money Back Guarantees