There are many free svn repository providers. If you are an individual developer, you may choose to use one of those. Some have the restriction that repository is publicly accessible such as google code and sourceforge, while others keep the repository private such as projectlocker and sliksvn. After reading the license agreements and contracts, I decided to maintain my own repository.
Warning:
This discusses how to set up and configured a svn repository on BlueHost using a windows 7 as the client machine: This setup is not for the faint of heart. It requires modifying configuration settings, compiling source code with multiple complex config options, generating ssh keys, setting up ssh, and properly configuring the windows environment. (NOTE: All of these steps can be followed for linux/bsd/mac. Slight modifications to the commands may be required, such as using forward-slashes for paths instead of back-slashes; using : for path separators instead of ';'; and other OS specific idiosyncrasies)
Quick Overview:
- Install SSH on the client
- Setup SSH Keys (you will have to contact bluehost directly to get permission to use SSH to access your server)
- Install an SVN Client
- Compile and Install the SVN Server from source on your bluehost box.
- Setup an ssh-svn service bridge (sshsvnserve)
- Instruct svn to use the service bridge when connecting to your repo.
- Using the repository.
- Properly backing up the repository (don't trust bluehost to back up the repository for you).
Getting Started:
Install SSH On Windows 7 (or any other version of windows)
I use mingw (which is minimal gnu for windows). This is an excellent package, and does not have all the complexities of cygwin. However, cygwin might work just fine. I don't use it because it tends to mess up gmake/gnu's make program.
- Download and install mingw from http://www.mingw.org/
- Assuming you installed at c:\MinGW, then add C:\MinGW\msys\1.0\bin to your system path environment variable.
- Confirm all is working by typing svn -v from any directory on your box, you should get:
C:\>ssh -v OpenSSH_5.4p1, OpenSSL 1.0.0 29 Mar 2010 usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname [command]
- Congrats! step 1 is done
Setup SSH Keys
SSH keys allow you to login to your account on BlueHost without the need for a password. It works by storing a private key on your computer, and you upload a public key to your account on the BlueHost box. You can then login using ssh, or interact using scp without specifying a password, by specifying the ssh private key file. The public and private keys are asymmetric keys. This means that which ever key is used to encrypt the data, the other key must be used to decrypt data. Authentication is accomplished by providing a challenge to the requesting client.
Assuming Step 1 was completed successfully, the ssh-keygen program should be in your path.
SSH keys allow you to login to your account on BlueHost without the need for a password. It works by storing a private key on your computer, and you upload a public key to your account on the BlueHost box. You can then login using ssh, or interact using scp without specifying a password, by specifying the ssh private key file. The public and private keys are asymmetric keys. This means that which ever key is used to encrypt the data, the other key must be used to decrypt data. Authentication is accomplished by providing a challenge to the requesting client.
Assuming Step 1 was completed successfully, the ssh-keygen program should be in your path.
- pick a directory to store your public and private key, and switch to that directory
A good choice would be -> c:\Users\[Windows User]\.ssh - Generate the public and private key, there are many options, choosing all defaults (with the exception of the file name) is typically good.
C:\Users\[My Account]\.ssh>ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (//.ssh/id_rsa): id_rsa_svn Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id_rsa_svn. Your public key has been saved in id_rsa_svn.pub. The key fingerprint is: 04:a3:1a:b7:5d:6f:29:39:bc:30:a3:c7:c6:b0:2f:49 [My Account]@[mycomputer's name] The key's randomart image is: +--[ RSA 2048]----+ | o | | . o | | . o o | | + o + o . | | . o = S + | | E* + = | | .o.= . | | o+ | | .. | +-----------------+Test out your SSH Key
- upload the public key to the bluehost server, KEEP the private key private! This is important because this protects the bluehost account from unauthorized access.
- Install the key in your authorized_keys file
- Test the access.
C:\Users\[Windows User]\.ssh>ls id_rsa id_rsa.pub id_rsa_svn id_rsa_svn.pub C:\Users\[Windows User]\.ssh>scp id_rsa_svn.pub [bluehost account]@[bluehost machine]:~/.ssh [bluehost account]@[bluehost machine]'s password: id_rsa_svn.pub 100% 401 0.4KB/s 00:00You will now need to log into the bluehost box, and manually add the public key to the authorized_keys file. To do this, log on to your bluehost account, and follow the following steps.
[bluehost account]@[bluehost machine] [~]# cd .ssh [bluehost account]@[bluehost machine] [~/.ssh]# dir ./ ../ authorized_keys2 environment id_rsa_svn.pub [bluehost account]@[bluehost machine] [~/.ssh]# cat id_rsa_svn.pub >> authorized_keys2 NOTE to see the changed file: [~/.ssh]# cat authorized_keys2Finally From the windows box, test out the key to make sure that it works:
C:\>ssh -i "c:\Users\[Windows User]\.ssh\id_rsa_svn" [bluehost account]@[bluehost machine] Last login: Thu Apr 28 17:08:06 2011 from 32.178.80.204 [bluehost account]@[bluehost machine] [~]#
Install An SVN client
Any svn client should do the job, SlikSVN seems to be a good distribution. However, many others will do the job. SlikSvn comes as a standard windows installer, it will typically add the subversion client tools to your path. Once it is installed on your windows box, test to make sure the svn.exe file is executable from any directory.
C:\>svn --version svn, version 1.6.16 (SlikSvn/1.6.16) X64 compiled Mar 3 2011, 22:35:47 Copyright (C) 2000-2009 CollabNet. Subversion is open source software, see http://subversion.apache.org/ This product includes software developed by CollabNet (http://www.Collab.Net/). The following repository access (RA) modules are available: * ra_neon : Module for accessing a repository via WebDAV protocol using Neon. - handles 'http' scheme - handles 'https' scheme * ra_svn : Module for accessing a repository using the svn network protocol. - with Cyrus SASL authentication - handles 'svn' scheme * ra_local : Module for accessing a repository on local disk. - handles 'file' scheme * ra_serf : Module for accessing a repository via WebDAV protocol using serf. - handles 'http' scheme - handles 'https' schemeCompiling SVN Server on BlueHost
- Download the latest version of Subversion from sourceforge.
- copy it up to the BlueHost Account
- configure the compilation process for BlueHost
- make the components
- install the svn server and libraries
[~]# cd src [~/src]# cd subversion-1.6.16 [~/src/subversion-1.6.16]# ./configure --prefix=$HOME/svn/bin --without-apxs --exec-prefix=$HOME/svn/lib --disable-mod-activation [~/src/subversion-1.6.16]# nohup make & [~/src/subversion-1.6.16]# tail -f nohup.out [~/src/subversion-1.6.16]# make install
Subversion server is now installed on BlueHost. At this point, it must be tested.
The following shell snippet shows the testing expectation:
[~]# cd svn/lib/bin [~/svn/lib/bin]# ./svnserve --version svnserve, version 1.6.16 (r1073529) compiled Apr 27 2011, 17:27:09 Copyright (C) 2000-2009 CollabNet. Subversion is open source software, see http://subversion.apache.org/ This product includes software developed by CollabNet (http://www.Collab.Net/). The following repository back-end (FS) modules are available: * fs_fs : Module for working with a plain file (FSFS) repository. Cyrus SASL authentication is available.
Setting up an ssh-svn service bridge:
In this step a bridge will be set up. The purpose of this bridge will be two things:
- Set up enough of an environment to execute svnserve command (by default and for security purposes bluehost disables shells and environments for remote logins)
- Instruct ssh to invoke a temporary service immediately on connect. (this service will of course be the svnserve command which serves content from an svn repository)
command="/home1/[your bluehost account]/sshsvnserve -t" ssh-rsa AAAABCCCCCCDDDDDDDD3NzaC1yc2EAAAADAQABAAABAQDJezPXNZb8rls8GrxH46zZwUO6vm1bkgxD2jma4RJMlXH0ADTDsQ2PGZAW80hVamojBsKGUN8zYH2i3LiEYiNSqL2d6mvFZAxIGH4mxhQQZdImyIWEnAK5a9HL9SQlIRnKa0ZEEsi/KWmiyB/gOXtKxxW7aU9KIsk2mjG0UZfmRHE4OhvXQqguAZCScOHh/WDRXiC2t2WbmfSXJK7KNz2sjla8Y62Z+u3Lg0m4SlmNqLgllh+tY0Nbxd623sJSQVqNwutPPMd1IhybjQskXUv8OlSmVepkhnGpSteRIzI99MocX8LzrZefHSaPsyMeHri52VzTb0 3 [windows usr]@[windows machine name]
The only thing added is the first command=..... up to the 'ssh-rsa' of course modified to match your account.
Now create the sshsvnserve shell script. This is a very simple shell script. Switch back to the home directory on the bluehost machine, and create a file with the following content. Note that you will have to change this file to executable before it can be used.
#!/bin/sh /home1/[your bluehost account]/svn/lib/bin/svnserve $*
Instruct svn to use the service bridge when connecting to your repo.
This is done by adding an ssh directive to your tunnels command. On the windows box, create a subversion config file as bellow.
C:\Users\[Windows Account]\.subversion>cat config [tunnels] ssh = ssh -i "c:\\Users\\[Windows Account]\\.ssh\\id_rsa_svn"
USING your new repository:
C:\repos>svn --config-dir="c:\Users\[Your Windows Account]\.subversion" co svn+ssh://[your bluehost account]@[your bluehost machine/ip]/home1/[your bluehost account]/repos
Using the repository
The repository can be used by simply making sure that the --config-dir option is specified, and points to the directory that contains your config file with the [tunnels] entry.
Backing up the Repository:
Assuming that you are using BlueHost for a single user or very small number of users, you can simply create a synchronized repository on your local machine. The steps will be outlined in a code snippet block, with comments.
# First create the repository. C:\repos>svnadmin create . # Modify the hooks so the repos can accept # backup requests from other repositories. C:\repos>cd hooks C:\repos\hooks>echo exit 0 > pre-revprop-change.bat C:\repos\hooks>cat pre-revprop-change.bat exit 0 # C:\repos>svnsync initialize file:///repos svn+ssh://[bluehost caccount]@[bluehost machine]/home1/[bluehost account]/repos --config-dir="c:\Users\[Windows Account]\.subversion" Copied properties for revision 0. C:\repos>svnsync synchronize file:///repos --config-dir="c:\Users\[Windows Account]\.subversion" Committed revision 1. Copied properties for revision 1. Committed revision 2. Copied properties for revision 2. Transmitting file data ....................................................................... .............................................................................................. ........... Committed revision 3. Copied properties for revision 3. Transmitting file data ....................................................................... .............................................................................................. ... Committed revision 4. Copied properties for revision 4. Transmitting file data .