Bluehost with SVN

Recently we have been tasked to provide SVN support with Bluehost.  Initially I was reading and found it was not possible to complete.  After a bit more searching I found that it was possible.  The steps here are not as simple as “apt-get install svn”, we actually have to compile it from source.  Since I have been extremely busy lately, I tasked my friend Henry for the job and then told him I could provide support when needed.

With the tutorial in hand, he went to work.  Here is the steps outlined in the tutorial:

cd ~
mkdir src
cd ~/src
wget http://www.gtlib.gatech.edu/pub/apache/apr/apr-util-1.2.12.tar.gz
wget http://www.gtlib.gatech.edu/pub/apache/apr/apr-1.2.12.tar.gz
wget http://subversion.tigris.org/downloads/subversion-1.5.4.tar.gz
wget http://www.webdav.org/neon/neon-0.28.0.tar.gz
tar -xzf apr-util-1.2.12.tar.gz
tar -xzf apr-1.2.12.tar.gz
tar -xzf subversion-1.5.4.tar.gz
tar -xzf neon-0.28.0.tar.gz
cd ~/src/apr-1.2.12
./configure --prefix=$HOME LDFLAGS="-L/lib64"
make
make install
cd ~/src/apr-util-1.2.12
./configure --prefix=$HOME --with-apr=$HOME LDFLAGS="-L/lib64"
make
make install
cd ~/src/neon-0.28.0
./configure --enable-shared --prefix=$HOME LDFLAGS="-L/lib64"
make
make install
cd ~/src/subversion-1.5.4
./configure --prefix=$HOME --without-berkeley-db  --with-ssl LDFLAGS="-L/lib64"
make
make install

After making it through all of the above configuring and compiling, the binaries are sitting in ~/system/bin ready for use.

Now to add a new repo, type:

svnadmin create /[dir]/[repo name]

Now import files to the repo:

svn import /[dir]/[repo name] [svn string, starting with svn://]

Now the repo is ready to add files or to check them out. But, you will soon learn that you need to add somethings to the path in order to properly execute. Once I added the things to the path, it still didn’t work. I found out that bluehost doesn’t allow execution of the .bashrc if it is a single execution item. I found a work around:

First you will have to add a public key to the .ssh/authorized_keys from your system so that you can login without using a password.  If you need help with that, here is an awesome tutorial that works very well! SSH Key Tutorial

Add the following before your rsa key in ~/.ssh/authorized_keys

command="/home/USERNAME/system/bin/svnserve -t" ssh-rsa [KEY REMOVED]

Now you should be able to login using the CLI for the system that you have added the key for and use SVN.

Now that you have everything else setup, it is time to get TurtoiseSVN client up and running.

First install Putty, if you need help with that, click here.

For those that didn’t click the link, click it for fun :D .

Next you are going to need to get WinSCP or Filezilla or some other program that can do file transfer over SSH.  I prefer Filezilla because it is Filezilla.  If you don’t have either of those, simply Google them and you’ll find them.

Ok, now you will need to log in to your Bluehost server with Putty.  Once you have logged in, type the following:

ssh-keygen -t rsa

This will create 2 files id_rsa and id_rsa.pub in the .ssh/ directory. First you will want to copy the public key to make it so you can use this key on this server, type the following:

cp .ssh/id_rsa.pub .ssh/authorized_keys

Now I will assume you are using Filezilla. Open Filezilla and then for the hostname, use “sftp://[domainname.com]” and your username and password. Navigate to the ~/.ssh directory and download id_rsa to a directory on your computer of your choosing.

When you downloaded putty, you should have also downloaded PuttyGen. Open PuttyGen and then select the Conversions menu and select Import Key. Find the id_rsa file you just downloaded and import it. After it is imported select the “Save Private Key” button and export the .PPK file to your choosing.

Now we are going to open Putty and save a new session with our newly created key. Once Putty is opened, go to SSH and then to AUTH and then select the private key you exported above. After that go back to the sessions option and type the whole domainname (including .com/.net/.whatever) as the “Saved Session” and push the Save button. It is important to save the session because Tortoise will use this in just a bit.

You can test your SSH login to make sure it doesn’t ask for a password and you will know that you are on the right path.

Next up, we have to make some changes to your Tortoise config file located at C:\Documents and Settings\YOUR_LOCAL_USERNAME\Application Data\Subversion\config
If you have Vista or Win7, it will be located here:
C:\Users\YOUR_LOCAL_USERNAME\AppData\Roaming\Subversion\config
Now find the section called [tunnels] and add the following:

ssh = c:\\Program\ Files\\TortoiseSVN\\bin\\TortoisePlink.exe

Link in Linux, you have to escape the backslashes with a backslash.

Ok, you should be ready to rock at this point. Time to install Tortoise if you haven’t already. Download it here. Follow the installer, should be easy.

Time to check something out. Try to checkout a repo now by right clicking in Windows Explorer and choosing “SVN Checkout.” Use the following string but add your own info:

    svn+ssh://youraccount@[domain]/home/[your account]/[repo path]/[Project]

Hopefully everything worked, if it didn’t, hit me up and I’ll help out.

Mike

    • Russ
    • July 5th, 2010

    What I’ve done:
    –> INSTALLED subversion 1.6 on our bluehost server
    [~]# svn –version
    svn, version 1.6.12 (r955767)
    compiled Jul 16 2010, 14:14:51

    Copyright (C) 2000-2009 CollabNet.
    Subversion is open source software, see http://subversion.tigris.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
    * 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

    –> SNV binaries:
    [~/bin]# ls
    apu-1-config* svnadmin* svnserve* svnsync*
    neon-config* svndumpfilter* svnssh* svnversion*
    apr-1-config* svn* svnlook*

    –> my .bash_profile has:
    PATH=$PATH:$HOME/bin

    –> created a new repo:
    [~/]# mkdir subv
    [~/]# cd subv
    [~/]# mkdir repos
    [~/]# cd repos
    [~/]# svnadmin create test_project
    [~/]# cd test_project
    [~/subv/repos/test_project]# ls
    ./ ../ README.txt conf/ db/ format hooks/ locks/

    –> Add project files
    [~]# cd $HOME/test_files
    [~/test_files]# tree -a
    .
    |– test1.c
    `– test1.txt
    [~]# svn import /home/[username]/test_files/ file:///home/[username]/subv/repos/test_project -m “Initial import”
    Adding /home/[username]/test_files/test1.c
    Adding /home/[username]/test_files/test1.txt
    Committed revision 1.

    –> logged into bluehost’s cpanel & created RSA key… specifically…
    KEY TYPE: RSA
    KEY SIZE: 4096

    this create an id_rsa & id_rsa.pub files @ ~/.ssh
    I then copied the rsa.pub key into the authorized_keys file:
    [~/.ssh]# ls
    ./ ../ authorized_keys id_rsa id_rsa.pub

    & added the snvserve command to the authorized_keys file:

    [~/.ssh]# cat authorized_keys
    command=”/home/[username]/bin/svnserve -t” ssh-rsa [public key] [username]@[box].bluehost.com

    –> Using WinSCP, I copyied the id_rsa file to my local Windows 7 System

    –> Using PuttyGen, Conversions -> Import Key -> imported id_rsa and saved the id_rsa.ppk file

    –> opened Putty and created a Saved Session under this id_rsa.ppk file. testing the connection resulted in the following:

    OUTPUT FROM PUTTY
    login as: [username]
    Authenticating with public key “imported-openssh-key”
    ( success ( 2 2 ( ) ( edit-pipeline svndiff1 absent-entries commit-revprops depth log-revprops partial-replay ) ) )

    –> Then – added the following command under the [tunnels] section in my Tortoise config file
    ### Section for configuring tunnel agents.
    [tunnels]
    ssh = C:\\apps\\development_tools\\tortoiseSVN\\bin\\TortoisePlink.exe

    (added extra “\” to the path – note – I installed Tortoise in unique directory)

    –> installed Putty, WinSCP, Tortoise

    –> restarted Win 7 system .. becauase … you never know.

    –> Now… this should work… :-) .. I open up Windows Explorer and navigated to an empty directory, right mouse clicked, and selected “SVN Checkout”

    Here I entered:
    svn+ssh://[username]@[username].com/home/[username]/subv/repos/test_project

    and I got a popup dialog box asked for password to log in (which defeats the purpose of the key)… Anyway, I entered the password. Not good, it kept asking for the password.

    Thus, I just hit cancel, and got the following errors:

    Command: Checkout from svn+ssh://[username]@[username].com/home/[username]/subv/repos/test_project, revision HEAD, Fully recursive, Externals included

    Error: To better debug SSH connection problems, remove the -q option from ‘ssh’ in the
    Error: [tunnels] section of your Subversion configuration file.
    Error: Network connection closed unexpectedly
    Finished!:

    Thoughts….

    Well… Sorry if I am missing something from the instructions above. I just cannot put my finger on it.

    Since I had to import a key into Putty – I was looking for the command to import a key into Tortoise on my Win7 box. I went into Tortoise’s Setting dialog, but could not find anyplace to import the key. Do I need to something with the key and Tortoise?

    Second – in various google searches – I found multiple references to subversion issues @ bluehost and how the environment variables are not loaded with new version of openssh that is running @ bluehost. So my question is, should I be adding anything to the [tunnels] section of the Subversion config file on bluehost??

    ($HOME/.subversion/config) ?

    Of course … many thanks up front for any help. Russ

    • Russ
    • July 5th, 2010

    ok – for the benefit of other’s, I’d like to followup on my progress.

    I was able to make the tortoise connection because – as I had suspected – Tortoise needs to know about the private/public key pairs.

    This was a good resource I found: http://tortoisesvn.net/ssh_howto

    Specifically, in my case, the SAVED SESSION name that was set in Putty needs to be added to the URL passed to the RepoBrowser. I probably did not read the original post carefully.

    So, for example, if your Putty SAVED SESSION name is – MYSSL_CONNECTION.

    then the URL passed to the Repobrowser should look like this:

    svn+ssh://[username]@MYSSL_CONNECTION/home/[username]/subv/repos/test_project

    note — before I had :

    svn+ssh://[username]@[username].com/home/[username]/subv/repos/test_project

    replace
    [username].com with MYSSL_CONNECTION

    similar to the original post above:

    svn+ssh://youraccount@[domain]/home/[your account]/[repo path]/[Project]

    just make sure the “domain” exactly matches what you saved in the “Saved Session” field within Putty.

  1. No trackbacks yet.