Updating / Moving and Administer a Git Server on OS X Lion using GitoLite
This is my re-installation of Gitolite server on Mac OS X Lion Server after I reformatted the server disk and installed the server from scratch. So this page will discuss how I did this time and how to migrate your projects to Lion. As far as I know beside the creation of the git user there is nothing else that requires a Lion Server but I did on a Lion Server so your milage might vary.
If you want to know why I used Gitolite or want to know how I did it the first time on Snow Leopard Server then checkout the original page.
having made changes to my Gitolite Server once more I ran into an reoccurring issue with SSH and it took me a while to figure out.
If you use the latest and greatest, removed the regular entries inside .ssh/authorized_keys (all lines that don’t start with command or a #) and you use the following:
ssh git@<server name or IP address>
you will see this message:
PTY allocation request failed on channel 0
Earlier on you have seen this right before the listing of the repositories are you access rights but now only this line appears. Eventually I found the answer here: http://groups.google.com/group/gitolite/browse_thread/thread/549752907f384d62 which was simple this:
ssh git@<server name or IP address> info
you will see this message:
hello XXX, this is gitolite v2.1-41-g582c187 running on git 220.127.116.11 the gitolite config gives you the following access: ... R W gitolite-admin @R_ @W_ testing
Below I mention that you need to remove the initial entry into the .ssh/authorized_keys we used to test the passwordless access to the server using SSH. The correct reason to remove the original line is to prevent any user to gain access to the box. You want to share the Git repositories and not grant access to the box. If you have a look at the lines that Gitolite generates you will see that it will only execute the command /usr/local/bin/gl-auth-command which provides the output in question.
End of UPDATE
The Rules ∞
- This installation is tested for Mac OS X Lion (10.7) Server
- Before tearing down the server make a copy (SuperDuper etc) of your server especially the directory /Users/git because it contains the repositories and configurations.
- Make sure that each step worked nicely
- I tested the installation on a Mac OS X server and on a workstation you need to create the user account yourself. Make sure that you can login as the given user git.
- SSH can be nasty at times so I make sure that it works before going on. This means we need to undo a step later but it is worth while.
- I did not try to clone a repository on the server
- Gitolite needs your public SSH key file from the workstation where you initially are going to configure the server. This also means that this is the only computer from where you can access the git server until you added new public SSH key files.
Keep in mind that for Gitolite a user is defined by the public SSH key. I managed to use the same SSH key on the same box but with different OS X installations and it might even work distributing the SSH on multiple boxes but I would not do that.
Installation Step of GitoLit ∞
- Create a user named “git” on the server with a home directory (assuming “/Users/git”) using WorkGroup Manager
- Copy the public ssh key (for example id_rsa.pub) from your local workstation onto the server (use “ssh-keygen -t rsa” to generate one inside the "~/.ssh" directory. Make sure that permission is set to “700” on the "~/.ssh" directory.
- Add the content of your public key file on the server into this file (create one if needed): ‘/Users/git/.ssh/authorized_keys’ and also make sure that the permission on the .ssh directory is set to 700.
- On the workstation try to log in using: ‘ssh git@
‘. If you can login without entering a password your are good to proceed. Otherwise you need to check the permissions as well as the content of the authorized_keys file that no character was dropped.
- On a clean installation of Lion there is no git software installed. It is best to download and install XCode4 which will install git on /usr/bin/git and it is automatically available to all users. Otherwise check out the instruction on the Snow Leopard installation.
- Make sure for the user git git is executable (if it reports the git help then we are good):
ssh git@<server name> git
- Login to your server and sudo (sudo -s) to become root
- Get the gitolite code:
git clone git://github.com/sitaramc/gitolite
Change into the ‘gitolite’ directory and execute this:
# Now become user “git” (IMPORTANT) using ‘su git’ (check with ‘whoami’)
- Change into the “gitolite/src” directory (from the code cloned above)
- Change the name of the public ssh key because Gitolite will use that as name for the virtual user
- Execute the setup with:
gl-setup <path to the renamed public ssh key>
- Because Gitolite is also installing the same public ssh key we need to go back to ‘/Users/git/.ssh/authorized_keys’ and delete the line we originally added to test the passwordless login
Now login into the server with SSH (ssh git@
) should display this:
PTY allocation request failed on channel 0 hello schaefa, the gitolite version here is v2.0.2-6-gfda9f37 the gitolite config gives you the following access: R W gitolite-admin @R_ @W_ testing Connection to 192.168.0.2 closed.
On the Snow Leopard instruction we checked out gitolite-admin but here we don’t need to do that because the previous installation
already has the configuration and repositories. So we only need to put them into place and we are done.
- Copy away directory .gitolite and repositories (rename them with a suffix like .origin) just to be on the safe side
- Copy the directories .gitolite and repositories from the previous server backup.
- Make sure the ownership is set correctly. The user number might have changed and so you would need to adjust that with chown -R git ….
- On the workstation use SSH to see if you get the full list of repositories:
ssh git@<server name>
If the list is complete you might want to clone all the repositories to make sure they are what you expect them to be
From now on you work with gitolite as we discussed this on the Snow Leopard instructions.