Archive for May, 2009
Hosting Git repositories on Dreamhost
Over the past weeks, I have been experimenting with different setups for hosting Git repositories. The environments where I tested these were very different: on my Dreamhost accout I can’t run daemon processes, while on the company server, I’m very well allowed to.
However, even with these different environments, I didn’t want to learn and maintain different Git hosting setups on each of these environments. In the end, I decided to go with Gitosis, a simple management system for Git repositories, where the communication between client and server is based on SSH and public/private keypairs.
I got Gitosis up and running quite fast on the company server. However, I have full control of this machine, and I can install all the required software I needed. On Dreamhost, it’s a completely different story.
Since Gitosis is mostly written in Python, I first checked for the Python version on my Dreamhost machine: 2.3.5. I decided to upgrade to a later version as per these instructions. I installed Python 2.6.2 instead of the mentioned 2.5.2. This was the latest stable version in the 2.6 range at the time of writing. Installation went fine.
Second pre-requisite for Gitosis is Git itself. The version of Git installed on my Dreamhost machine was 1.5.4.1. Time to upgrade! I followed the instructions from this article, but updated the prefix argument of the configure script to als put the files in $HOME/opt, next to my custom Python distribution.
Before you continue with installing Gitosis, first install the Python setuptools. Download the latest setuptools egg and install it in your private Python distribution.
$ wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c9-py2.6.egg $ sh setuptools-0.6c9-py2.6.egg
Now you can continue with the installation instructions for Gitosis from the article mentioned before. Since I installed a custom Python distribution, I can skip setting the PYTHONPATH. The custom Python has it’s module search path set correctly already.
In a previous article, I discussed a passwordless SSH setup. I assume you have your public key already copied to the Git user account on Dreamhost. If so, you can initialize Gitosis as follows:
$ gitosis-init < /tmp/id_rsa.pub Initialized empty Git repository in /home/mygituser/repositories/gitosis-admin.git/ Reinitialized existing Git repository in /home/mygituser/repositories/gitosis-admin.git/
Now that Gitosis is installed successfully, I continued reading on how to add users and repositories. Quite simple actually!
1 commentSSH, multiple identities, but no passwords!
Secure Shell is a great tool for securely connecting between several machines. In the past weeks, I am using it more and more, but I was getting tired of typing too much. I found a great article on setting up passwordless authentication using public/private keys and defining multiple SSH identities, but it still wasn’t enough.
I manage multiple Unix users on Dreamhost, a plethora of Linux virtual machines at work, running Hudson builders and two additional machines at home. With ssh-keygen, you can generate multiple different public/private keypairs (aka an identity). The section “Selecting Keys” of the above mentioned article describes how you can select a specific identity for connecting to a specific host. The example below shows how to connect to one of my DreamHost user accounts in a passwordless manner:
ssh -i ~/.ssh/dh-user1 user1@boba.dreamhost.com
If you have a long list of accounts, it would definitely be easy to use shortcuts for every combination of user@host and link that up to a specific SSH identity. Well, this is possible with the use of an SSH config file. I found out about this file here and then read more about it in the man page.
When you have user1 and user2 as accounts on your remote machine, in my case boba.dreamhost.com, and having different SSH identities for each user (dh-user1[.pub] and dh-user2[.pub]), how do you link everything together to be able to just type one of the following:
ssh dh-user1
ssh dh-user2
Actually, this is quite easy. Here is the ~/.ssh/config file in my local account (the account I’m making SSH connections from):
Host dh-user1
User user1
HostName boba.dreamhost.com
IdentityFile ~/.ssh/dh-user1
Host dh-user2
User user2
HostName boba.dreamhost.com
IdentityFile ~/.ssh/dh-user2
Every section in this file starts with Host ConnectionName followed by a number of connection parameters that are fully described in the man page. In my case, I specify the real host name, the username on the remote machine, and the identity file I want to link to that account.
Done!
1 comment