SVN Overview
SVN is a replacement for CVS, the concurrent versioning system. This allows you to keep track of multiple revisions of files and directories. It is commonly used in code development tasks.
For detailed instructions, check out the SVN documentation at:
This book includes a high-speed tutorial here, which will help you create a repository, import files into it, and check them out using SVN software:
Creating an SVN repository
Log in to the Linux shell for your account and execute the following command to create an SVN repository
svnadmin create /path/to/repos/
Where /path/to/repos/ is the name you'd like to set for your repository (no spaces), e.g. /home/username/svn/.
Choosing your SSH authentication method
You are required to use SSH to connect to SVN repositories on the Sisfo Hosting server, rather than using http or https connections.
SSH provides several options for authentication, including password and Public Key. The SVN client often makes multiple connections to a repository, and SSH will authenticate for every outbound connection. To avoid the annoyance of having to repeatedly enter a password, you should either use a SSH password-caching tool (such as ssh-agent on a Unix-like system, or pageant on Windows) or use the Public Key authentication method with no passphrase. This article assumes that you will use the latter; if you choose the former you should skip the sections concerning key-pair generation in the usage intructions which follow.
SVN client usage instructions
Windows
Overview
The initial setup is a three-stage process involving the generation of a key-pair for Public Key authentication, configuring your SSH client to connect to the Sisfo Hosting server, and configuring your SVN client to use SSH. Each is dicussed in detail below, with step-by-step examples provided.
Key-pair generation
The basic steps which you need to follow are:
- Generate a key-pair on your local machine
- Upload your generated public key file to the Sisfo Hosting server, and add it to the authorization list
OR
- Generate a key-pair on the Sisfo Hosting server
- Securely download your generated private key file to your local machine
The first method is rather better as it does not require your private key to be transported.
Either of these options can be carried out with ease by installing and using an SSH client on your local machine. (This client can also be used to obtain shell access to the Sisfo Hosting server, a useful feature in its own right.)
We recommend you use a freely-available client called PuTTY which is available from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and then follow the steps below to perform the key generation and upload using this client. PuTTY is the default SSH handler used by TortoiseSVN, and it is capable of using the same key-pair file format as our SSH server, unlike some other SSH clients (such as the 'SSH Secure Shell' client). You will need to download the following two applications from the PuTTY website:
* putty.exe
* puttygen.exe
Using PuTTY to generate the key-pair
In this example, we will use PuTTy to generate the key-pair on the server and download the private key.
1. Run PuTTY and log into the Sisfo Hosting shell using your shell username and password.
2. Create a directory called .ssh in your home directory:
mkdir .ssh
3. Generate a key pair:
ssh-keygen -b 1024 -t dsa -f mykey
Do not enter a passphrase, merely hit enter.
4. Copy the public key file to the .ssh dir:
cp mykey.pub .ssh/authorized_keys
5. Download mykey (not mykey.pub) via ftp or through cpanel's file manager to your desktop
6. Open PuTTYgen on your desktop.
7. Choose Conversions -> Import Key. Choose the mykey file
8. Click "Save Private Key". Save as mykey on desktop (file will have a ppk extension. Close PuTTYgen.
Configuring your SSH client to connect to the Sisfo Hosting server
To set up the connection you should run PuTTY (the procedure will be similar for all SSH clients) and:
- Input your server name in the hostname box
- Input 7822 for the port
- Put a session name in saved session. No spaces please, these will cause issues later.
- In the options tree on the left-hand side, click on SSH->Auth. Under "Private key for Authentication", browse to the mykey.ppk file that you created in the previous section. (Leave blank if you are using password authentication instead.)
- Click back on session, and click save.
- Double click on the newly-saved session and enter your username when prompted.
You should be logged in without needing to input a password. If you do need to input a password, please go back and review the previous steps.
Configuring SVN to use SSH
It is recommended that you download and use the popular TortoiseSVN client to manage your SVN projects.
Assuming that PuTTY will handle your SSH connections, you should use the following repository URL to connect to an SVN repository on the Sisfo server:
svn+ssh://username@profile_name/home/username/repository_path
where username is your shell username; profile_name is the saved profile/session name in PuTTy; the second username is your username again; and the rest of the string is the rest of your repository path relative to your home directory on the server.
Replace profile_name by your domain name (eg. example.com) or IP address if your SSH connections are performed by an SSH client which connects directly without using profiles.
The easiest way to test that you have the correct URL format is to create a test repository on the server and attempt to browse it as follows:
- Right-click on any Windows folder and choosing TortoiseSVN->repo-browser.
- Input the URL as described above
- Attempt to browse the repository. If everything is correct you will be able to browse it without receiving error messages.
[Note that TortoiseSVN defaults to using PuTTY to handle your SSH connections. During installation, TortoiseSVN registers itself as a handler for the svn+ssh protocol, and by default it calls upon an application called TortoisePlink (which is based on PuTTY) to deal with the SSH connection. This application uses the profile/session settings created by PuTTY, and this whole process is usually invisible to you.]
Troubleshooting
If you experience errors, please re-check your setup. If you have rechecked your setup, and it still is not operation, please file a ticket at support.sisfo.com, and we will check the operation of svn on the server. Thanks.
Mac OS X / Linux
1. Download an SVN client at http://subversion.tigris.org/project_packages.html
2. If you haven't already, you'll want to generate an SSH key pair so that you can set up automatic authentication (passwordless login). If you've already generated a DSA key pair, skip to step 4.
Open a Terminal window. (On OS X, you can find this in /Applications/Utilities/Terminal)
3. Generate a key:
ssh-keygen -b 1024 -t dsa
Do not enter a passphrase. Hit enter when prompted for one.
4. Execute the following to display your public key:
cat ~/.ssh/id_dsa.pub
Copy the output to the clipboard.
5. Log into your account's shell via SSH. Once you're logged in, execute
cd .ssh
If the directory doesn't exist, create it:
mkdir .ssh
cd .ssh
6. Execute the command
vi ~/.ssh/authorized_keys
Hit i to enter Insert mode and then paste your public key (if there is already a key in this file, move to the bottom before pasting). Hit the ESC key to leave Insert mode and type :wq and hit enter to save and exit vi.
7. Because SVN access is provided via SSH, and because sisfo uses a custom port for SSH connections (7822), you'll need to tell Subversion to use the custom port. The best way to do this is to create a custom protocol for Subversion to use only with sisfo (allowing you to still use SVN+SSH on other servers that use the standard SSH port (22).
Edit the file ~/.subversion/config and under the [tunnels] section, add the following line:
sisfo = ssh -p 7822
8. Now that your sisfo protocol is created and your public key is listed in the remote authorized_keys file, you should now be able to check out from your repository with the following command:
svn co svn+sisfo://username@example.com/home/username/repository_path
SVN and Eclipse
Once you have set up a repository on your server, please follow these instructions to use SVN on Eclipse.
To use the popular Eclipse program with subversion, you need to download and install the 'subclipse' package from subversion:
You also need to download the Web Tools Platform:
Once you have done this, go to the Window... Preferences. Navigate to Team > SVN and set 'SVN interface' to 'SVNKit (Pure Java)'.
Click OK.
Now go to Window...Open Perspective...Other... Select 'SVN Repository Exploring' and click OK.
In the 'SVN Repository' window, right-click and select New... Repository Location.
The URL is in the format:
svn+ssh://username@server_ip_address/home/username/path/to/repos/
username is your sisfo username - server_ip_address is the IP address of your server
Click 'Finish' and you will be taken to the 'Enter SSH Credentials' page.
Your username will be pre-filled. Select 'Use password authentication', and enter your password. The sisfo port number is 7822. Check 'Save Information' if you want to, and click OK.
Eclipse will now load your repository in the 'SVN Repository' window. For instructions after this point, please visit the SVN documentation sites linked to above.
Sharing one login account
cPanel allows one shell login per account, which can be limiting if you have multiple developers and want to track commits from each one individually. SVN account sharing will show you how to set up multiple SVN users with only a single login and SSH RSA keys. It is not as complete a solution as using a VPS or Dedicated server with multiple individual accounts, full control over user groups, etc. But for a single repository on a shared server, it's a decent solution that's quick to set up.
