Install git && gitolite on CentOS 6


Install git and gitolite on a Centos 6 server using ssh. gitolite is being used here because gitosis is no longer supported.


Install the git and gitolite packages, add the gitolite user. Generate or use your pub/priv keychain to enable passwordless logins for SSH and add your pub key to the gitolite users authorized keys. Clone the gitolite adminitrative configs and configure for administration.


Install git

[root@box]# yum install git*

Then, enable EL repo for gitolite, and install gitolite

[root@box]# yum install gitolite
Next, setup the gitolite user and home directory. This must be done in a SELinux safe directory, so use /var/lib/gitolite or have a headache.
[root@box]# usermod -d /var/lib/gitolite gitolite

Generate your pub/private keypair to use as passwordless SSH entry

[user@box]$ ssh-keygen -t rsa -b 2048 -C $(whoami)
 ssh-keygen -t rsa -b 2048 -C $(whoami)
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mgill/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/mgill/.ssh/id_rsa.
Your public key has been saved in /home/mgill/.ssh/
The key fingerprint is:
8d:9d:6b:21:c8:8a:df:e4:ec:e6:f5:87:41:18:2b:41 mgill
The key's randomart image is:
+--[ RSA 2048]----+
|     .E          |
|      . .        |
|       . +       |
|     ...o+..     |
|      o.S.=      |
|   . .   ..o     |
|  . . . . oo     |
|   . =.. o. .    |
|    .+*   ..     |
[user@box]$ cd ~/.ssh/
[user@box]$ pwd
[user@box]$ file ASCII text, with very long lines

After creating your private key (~/.ssh/id_rsa) and your public key (~/.ssh/, get it on your server. Note: don’t move or copy your private key unless you know the risks

[user@box]$ scp ~/.ssh/`whoami`.pub

Now, on your server, we will setup gitolite by changing your user and installing the public key we just uploaded. You do not need to modify the gitolite config

[user@box]$ sudo su - gitolite
[sudo] password for user: 
-sh-4.1$ pwd
-sh-3.2$ gl-setup /tmp/

Verify that the key was installed correctly and you’re ready to move forward. By default everything should be good to go on CentOS 6, mileage *may* vary on different distros.

[user@box]$ ssh info
hello user, this is gitolite 2.3.1-1.el6 running on git 1.7.1
the gitolite config gives you the following access:
     R   W 	gitolite-admin
    @R_ @W_	testing

Make sure to configure git before you use it

[user@box]$ git config --global "ModifyMyUser"
[user@box]$ git config --global "fakeEmailAddress@no.where"

Now clone your gitolite-admin repo to manage it

[user@box]$ git clone
loning into 'gitolite-admin'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
Receiving objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0)

Now read and have fun!

This entry was posted in systems. Bookmark the permalink.

2 Responses to Install git && gitolite on CentOS 6

  1. manijshrestha says:

    Great post,
    Helped me setup gitolite. One last thing I would love to have added is the adding other users. It took me a while to figure out that we needed to actually clone “gitolite-admin” and add the keys and push it before they can access it. Hope this helps others…
    More info:

  2. Soroush says:

    Thanks a lot! Worked like a charm! :x

Leave a Reply

Your email address will not be published.