How to install gitosis on Ubuntu
In the previous post we went over installing git on Ubuntu, we are now installing a package called gitosis so we can host git repositories.
First, make sure you have python-setuptools package installed since gitosis needs python. Open the terminal window and type:
sudo apt-get install python-setuptools
Now we need to get gitosis, type these commands one after another to create src folder in your user directory, clone the source and install it:
cd ~/
sudo mkdir src
cd src/
sudo git clone git://eagain.net/gitosis.git
cd gitosis/
sudo python setup.py install
Next, lets create a user that will own the repositories.
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
Now we need a public ssh key, we’ll create a local one, it will ask you for a passphrase, enter the one you like:
ssh-keygen -t rsa
Now we need to let the git user use this key:
cp ~/.ssh/id_rsa.pub /tmp/
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
Now lets change the permission on on post-update hook:
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
Now lets clone gitosis-admin repository (you can get the hostname by typing hostname command in the terminal), navigate to the folder you want the repository to reside in and type:
sudo git clone git@YOUR_SERVER_NAME:gitosis-admin.git
That’s it, you got a local gitosis-admin repo with a config file and a keydir directory.
I will post how to use git and will try to install gitweb (convenient web interface) next.
Edit: I wrote another post on how to install gitweb in Ubuntu if you wish to move on to the next step. 🙂