This page looks best with JavaScript enabled

Git server installation using gitolite

 ·  🎃 kr0m

Git is a version control system, which means that if we make any mistakes in the development of an application, we will always have the option to go back to a safe point where everything was working correctly. In this article, I will explain how to set up a git server on my preferred distro Gentoo using gitolite.

We will start with the installation of the software itself:

emerge -av dev-vcs/gitolite

We add the git user:

useradd -g git -G git -s /sbin/nologin -d /dev/null gitdaemon

The configuration of gitolite itself is done through a repository, in this step we are going to add the masterkey, which will be used to clone the config repo:

su git -s /bin/bash
ssh-keygen -t rsa
cd ~
mkdir -p ~/bin
git clone git://github.com/sitaramc/gitolite
/var/lib/gitolite/gitolite/install -ln ~/bin
mkdir -p /var/lib/gitolite/.gitolite/logs
cd ~/bin
./gitolite setup -pk ../.ssh/MASTERKEY.pub
echo ’export PATH=/var/lib/gitolite/bin:$PATH’ » ~/.bash_profile

We start the service:

exit
mkdir /var/git
/etc/init.d/git-daemon start
rc-update add git-daemon default

Git relies on ssh to transfer data, so we configure any ssh peculiarities such as changing the port…

vi .ssh/config

Host localhost
  HostName localhost
  User git
  Port 22

We clone the configuration repository:

git clone git@localhost:gitolite-admin.git

We tell gitolite who we are:

git config –global user.email “ kr0m@alfaexploit.com
git config –global user.name “kr0m”

Usually, git is not managed from the server itself, but administrative users are registered:

cd gitolite-admin/keydir
vi kr0m.pub
cd ..
cd conf

We add the user kr0m and remove the test repo.

vi gitolite.conf

repo gitolite-admin
  RW+ = id_rsa kr0m
cd ..
git add keydir/kr0m.pub
git add conf/gitolite.conf
git commit -m “added kr0m to gitolite-admin”
git push

Now we can clone the repo from the PC where kr0m’s key is located.

vi .ssh/config

Host A.B.C.D
  HostName A.B.C.D
  Port 22
git clone git@A.B.C.D :/gitolite-admin

From now on, all administration will be done from this PC.

We add our repo:

cd gitolite-admin/
vi conf/gitolite.conf

repo alfaexploit
    RW+     =   kr0m
git add conf/gitolite.conf
git commit -m “added alfaexploit repo”
git push

We clone the new repository:

cd ~
git clone git@A.B.C.D :/alfaexploit

This has been a brief introduction to gitolite and its configuration. In later articles, we will talk about git in more depth.

If you liked the article, you can treat me to a RedBull here