How to install your own git server using gitolite

This example would show you how to install git server(gitolite) on linux server, Let’s begin.

1. System requirements

You must have following system components installed:

git 1.6.6 or later

check git version as follows:

git --version

if git is not installed , you can use:yum install git-core to install git-core on your machine.

perl 5.8.8 or later

check git version as follows:

perl --version

openssh 5.0 or later

check ssh version as follows:

ssh -v localhost

the commands are as follows:

[[email protected] ~]# git --version
git version 1.7.1

[[email protected] ~]# perl --version
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi

[[email protected] ~]# ssh -v localhost
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013

2. Setup a dedicated user id for git server

To install gitolite server, you must have a dedicated git user, let’s assume its name is gituser

  • create the user git user login as root and input commands like these:
	useradd \
        -r \
        -c 'git version control' \
        -d /gituser \

Here we create a user named gituser ,whose home directory is /gituser,it should not exist now, Let’s create it.

  • Create the home directory for gituser login as root, and input commands like these:
[[email protected] ~]# mkdir /gituser
[[email protected] ~]# chown gituser:gituser /gituser

Now you have gituser and setup its home directory ,and let’s continue.

3. generate the git key-pair files

Git would use RSA based public-private key files to authenticate each user.So we need to prepare one when install it. If you already have RSA key files, then skip this step, otherwise, you can do as follows:

[[email protected] ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): id_rsa_gitroot
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_rsa_gitroot.
Your public key has been saved in
The key fingerprint is:
b5:75:33:58:11:f1:5d:0x:6a:66:a4:4e:99:46:8x:e4 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|     ...... +=o .|
|     ....= ..+ o.|
|      F * * o = .|
|       + = o . o |
|        D .      |
|                 |
|                 |
|                 |
|                 |

[[email protected] ~]# ls -l id_rsa*
-rw------- 1 root root 1675 Feb  2 15:22 id_rsa_gitroot
-rw-r--r-- 1 root root  399 Feb  2 15:22

Be care , we use empty password to generate the pub-private files.Download these files to your laptop, Take care of them , not lose them.

4. Install gitolite

Now everything is prepared, let’s begin to install gitolite server now. login as root and input the following commands:

[[email protected] ~]# su - gituser
[[email protected] ~]# cd /gituser
[[email protected] ~]# git clone git://
[[email protected] ~]# mkdir -p $HOME/bin
[[email protected] ~]# gitolite/install -to $HOME/bin

If no error message found, then your gitolite server is just ok now , and the last step :

You should upload your file to /gituser and then do as follows:

[[email protected] ~]# $HOME/bin/gitolite setup -pk

And now your gitolite server is up and you can open git client in your windows laptop, and clone like this:

git clone ssh://[email protected]:YOUR-SERVER-SSH-PORT/gitolite-admin

Notes: you should firstly add your private ssh-key file to your git client.

You can find detail documents about the gitolite here: