Joe Maller.com

How to install Git on a shared host

I got a lot of really positive feedback for my installing Subversion on a shared host piece, but now that I’ve mostly switched over to Git, I figured I might as well write a companion post.

These instructions are much simpler, the installation is fast, and, like most things Git, it just works.

As with my previous Subversion solution, this will be a barebones install. It’s almost certainly against the terms of your hosting plan to run any daemons. The purpose of this installation is to be able to push changes from remote repositories into the hosted repo, where the hosted repository may also serve as the source directory of the live website.

Installing Git

SSH into your webserver. I created a source directory to hold the files which made cleanup easier:

$ cd
$ mkdir src
$ cd src

Grab the most current source tarballs from the Git site. At the time this post was last updated, the most recent version was v1.7.0.1:

$ curl -LO http://kernel.org/pub/software/scm/git/git-1.7.0.1.tar.gz

Untar the archive and cd into the new directory:

$ tar -xzvf git-1.7.0.1.tar.gz
$ cd git-1.7.0.1

This next step is the only one that really seems to matter with regards to shared hosting. The Configure script needs to be told where to install, and because we’re on a shared host, Git’s files should be put into our home directory:

$ ./configure --prefix=$HOME
[words...]

Lastly, make and install:

$ make && make install
[lots of words...]

That should be it, check your installed version like this:

$ git --version
git version 1.7.0.1

It's now safe to delete the src folder which contained the download and source files.

Note that these instructions do not install Git's documentation man pages. Also, these instructions appear to work exactly the same on Mac OS X (only tested on 10.5.4), though the installer package is way easier and includes documentation.


SSH Key Pair troubleshooting

For some reason I’ve put off setting up SSH key pairs, probably having something to do with how arcane most of the setup instructions appear. Tonight however, I’m unexpectedly preparing to transfer a client to a new hosting account on Media Temple and enjoying key-pair access to their new repository.

Media Temple doesn’t yet support svn:// access to Subversion repositories, only svn+ssh://. So, having been pushed, I finally decided to make my life easier with SSH key pairs.

The best tutorial I found was Allan Odgaard’s: Subversion support and ssh key pairs. Without ssh key pairs, all the fantastic Subversion integration in TextMate won’t work with svn+ssh:// repositories.

However there’s one crucial piece of information missing from that: Permissions.

If access to the SSH configuration files is not properly assigned, the ssh pair won’t work. No meaningful errors at connect time, just silent, infuriating failure.

The ~/.ssh directory permissions need to be set to 0700 and the authorized_keys file needs to be set to 0600:

chmod 0600 ~/.ssh/authorized_keys
chmod 0700 ~/.ssh

If group or world have write access to authorized_keys, key pair authentication will fail.