Installing gitosis on Mac OS X
Garry Dolley’s guide to gitosis installation is excellent and to the point. For those who don’t know, gitosis is a nifty tool that helps you host git repositories via one shared SSH account. gitosis manages access control for you, so you no longer need to rely on the capricious UNIX permission/group settings which is the major headache for hosting your own git repository using ssh://.
Garry’s guide is written mainly for Linux users. For Mac OS X developers, there are a few minor things to take care of, and a few others to skip. For example, /usr/local/bin is not the default path on OS X. On the other hand, you don’t need to install Python. Creating user account is a bit different too.
So here’s a short step-by-step instruction on how to setup gitosis on Mac OS X:
- I assume you already have git installed. If you don’t get the latest git for Mac OS X. The quickest way is to get the binary package prepared by Tim Charper and gcheshire. Get it here. Consider getting gitx too.
- Install it (you need to sudo):
sudo python setup.py install
- Now, create a new user from System Preferences > Accounts. Add a standard user will do. There’s no need to make it an admin account. Let’s call it “git”.
- Login with the just created user account. Create .bashrc, fill in the line below:
PATH=/usr/local/bin:/usr/local/git/bin:$PATH
This is because on Mac OS X, /usr/local/bin is not in the system’s default exported path setting. We need path access to the directories above.
- Now, assuming you’ll be the first user and the admin, you want to use your own public SSH key to access the shared account (that’s the whole point–more on this later). Get your id_rsa.pub onto the target server, or generate using ssh-keygen -t rsa on your local machine. If you don’t know what I’m talking about, read some tutorial on SSH authentication. A quick guide like this is a good start. Be sure you already know that before you move on–this is the crucial part of using gitosis.
- After you get your id_rsa.pub onto the target server, login to the server with an account with sudo access (which you don’t with the standard user account we just created above). Then do:
sudo -H -u git gitosis-init < [path of your id_rsa.pub]
- Now login with the standard user account “git”. In your home directory there is already a repositories/ directory, in which you’ll find gitosis-admin.git
- Make sure the post-update hook is executable. Do this:
chmod 755 ~/repositories/gitosis-admin.git/hooks/post-update
Find a working directory you like on the target server, then check out gitosis:
git clone git://eagain.net/gitosis.git
From this point on, read Garry’s guide to understand how to manage the admin repository. This is where gitosis is brilliant–you also use git to fetch and update the admin settings! Once you have finish creating your first gitosis-managed repository, the rest is easy. In fact, in our cases, we simply just moved all our bare repositories to under the standard user account’s repositories/ directory. We updated the gitosis config and we got it up and running well.
lukhnos :: Jan.06.2009 :: announcement :: 3 Comments »