Tag Archives: gitolite

How to configure gitolite on the Cubieboard running Cubian

In my previous post I outlined the steps I took to install git and gitolite on the Cubieboard, on top of Cubian X. In this guide I’ll show you what I did to:

  • add a new user to my git server
  • create a new empty repository
  • import my existing repositories from my old Digital Ocean server
  • import my GitHub repositories

How to add a new user to gitolite

  1. First, clone the gitolite-admin repository on your local machine, if you haven’t done so already:
    git clone git@ gitolite-admin-cubie
  2. Inside the gitolite-admin-cubie directory you should have two directories: conf and keys. To add a new user, you basically need to add her key to the keys directory. Note that you can create subdirectories under keys. Let’s assume you want to add a new user, and you have the public key: mary.pub. Note that you will use the corresponding private key to authenticate to git.
    • Copy the two public key to the key folder.
    • Add the key, commit the changes and push to the server:
      git add keys/mary.pub
      git commit -m Add Mary's keys.
      git push origin master

Now, user Mary should be able to access the git server using her private key.

How to create a new empty repository and give rights to it

  1. Edit conf/gitolite.conf:
    nano conf/gitolite.conf

    Initial file looks something like this:

    repo    gitolite-admin
            RW+     =   john
    repo    testing
            RW+     =   @all

    To add a new repository “myapp” and give user Mary full access to it, change it to:

    repo    gitolite-admin
            RW+     =   john
    repo    testing
            RW+     =   @all
    repo    myapp
            RW+     =   mary

    If you want user John to have access too, do something like:

    repo    gitolite-admin
            RW+     =   john
    repo    testing
            RW+     =   @all
    repo    myapp
            RW+     =   mary john

    You can read a lot more about the gitolite configuration file here.

  2. Add, commit, and push the changes:
    git add conf/gitolite.conf
    git commit -m "Add new myapp repo."
    git push origin master

Now Mary can do something like:

git clone git@

to clone the new empty repository.

How to import repositories from another server

  1. First, on your local machine, change the gitolite.conf file to add a new empty repository. You will import your existing repository into this new empty one.
    repo    gitolite-admin
            RW+     =   john
    repo    testing
            RW+     =   @all
    repo    myapp
            RW+     =   mary john
    repo    awesome-app
            RW+     =   john
  2. Add, commit, and push the changes:
    git add conf/gitolite.conf
    git commit -m "Add awesome-app repo."
    git push origin master
  3. On your Cubieboard, change to user git, change to the repositories folder and you should see the new empty repository awesome-app.git:
    sudo su git
    cd /home/git/repositories
    ls -la
  4. Change to the awesome-app.git directory and import your code from your remote server:
    cd awesome-app.git
    git --bare fetch git@existing-server.com:/awesome-app.git master:master

    This assumes you already have access to your existing git server from the Cubieboard. To set that up you basically need your private key for your existing git server in /home/git/.ssh and you need to edit your /home/git/.ssh/config file adding the following lines:

    Host existing-server.com
        Hostname existing-server.com
        User git
        IdentityFile /home/git/.ssh/existing-server-key
        ServerAliveInterval 300
  5. On your local machine you can now clone your imported repository, from your Cubieboard:
    git clone git@

Importing GitHub repositories

Importing your GitHub repositories is similar to importing repositories from your existing server. You just need to:

  1. Make sure you configure GitHub access on your Cubieboard, under user git.
  2. On your local machine, add a new empty repository by editing gitolite.conf and pushing the changes to the Cubieboard server.
  3. On your Cubieboard, switch to user git, change to the new empty repository and do something like:
    git --bare fetch https://username@github.com/username/repository.git master:master

If you have any questions, feel free to use the comments form below.

How to install git and gitolite on the Cubieboard with Cubian

I’ve been using a Digital Ocean droplet to run git, gitolite and GitList, to host my private git repos for some time, but I recently decided to switch to a Cubieboard, because it’s more fun and an easy way to save about $10/mo. In this post I’ll show you the steps I took to install git and gitolite on the Cubieboard, using Cubian X.

  1. Install git and gitolite:
    sudo apt-get install git gitolite
  2. Add an user to handle gitolite:
    sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git

    The code above creates the git user, without password, so direct logins are not possible.

  3. Switch to the git user:
    sudo su git
  4. Change directory:
    cd /home/git
  5. Generate a RSA key:
    ssh-keygen -t rsa

    You can safely accept the defaults. You should get something like this:

    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/git/.ssh/id_rsa): 
    Created directory '/home/git/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/git/.ssh/id_rsa.
    Your public key has been saved in /home/git/.ssh/id_rsa.pub.
    The key fingerprint is:
    4c:44:82:2e:ad:86:4e:9a:83:ef:e9:97:84:46:2d:d9 git@cubie
    The key's randomart image is:
    +--[ RSA 2048]----+
    |         +o      |
    |        oo*      |
    |   + o o.o       |
    |  + F o.o        |
    | . + o *S        |
    |  + . .. .       |
    | o o .  .        |
    |  o o            |
    | ...             |
  6. Still as the git user configure gitolite:
    gl-setup /home/git/.ssh/id_rsa.pub

    You should get the following output:

    The default settings in the rc file (/home/git/.gitolite.rc) are fine for most
    people but if you wish to make any changes, you can do so now.
    hit enter...

    Press the Enter key on your keyboard then you can just save the file and exit. If you’re using nano, just press CTRL+O and then CTRL+X.

  7. Copy the id_rsa (not the id_rsa.pub) file from /home/git/.ssh to your local computer.
  8. Configure SSH access to your Cubieboard for the git user. On a Mac you would place your id_rsa file (you can rename it) in your home folder, under .ssh, and you would edit the config file under .ssh by adding something like this:
        User git
        Port 36000
        IdentityFile /Users/your-username/.ssh/cubie_id_rsa
        ServerAliveInterval 300

    Now, if you do ssh git@ you should get something like:

    hello id_rsa, this is gitolite 2.3-1 (Debian) running on git
    the gitolite config gives you the following access:
         R   W 	gitolite-admin
        @R_ @W_	testing
    Connection to closed.
  9. You can now clone the gitolite-admin repository (which is used to change the gitolite configuration) from your Cubieboard to your local computer:
    git clone git@
    1. git and gitolite installation is now complete. In my next post I’ll show you how to actually configure gitolite, how to add new users and new repositories.