(step 1) Install dependencies


# Install dependencies (On Debian/Ubuntu)
root# apt-get install build-essential libssh2-1 libssh2-1-dev cmake libgpg-error-dev

# Install dependencies (On Fedora/CentoS/RedHat)
root# yum groupinstall "Development Tools"
root# yum install libssh2 libssh2-devel cmake libgpg-error-devel

If you’re using Bitnami Redmine Stack you must run this before doing anything to prepare the installation : Bitnami Installation.

(step 2) Clone the plugin


Assuming that you have Redmine installed :

# Switch user
root# su - redmine

# First git clone Additionals
redmine$ cd REDMINE_ROOT/plugins
redmine$ git clone --branch 3.0.6 https://github.com/AlphaNodes/additionals.git

# Then Redmine Git Hosting plugin
redmine$ cd REDMINE_ROOT/plugins
redmine$ git clone https://github.com/jbox-web/redmine_git_hosting.git
# last release version is broken, use master branch till next version released!
# redmine$ cd redmine_git_hosting/
# redmine$ git checkout 6.0.0

# Install gems and migrate database
redmine$ cd REDMINE_ROOT
redmine$ bundle config set --local without 'development:test'
redmine$ bundle config set --local build.rugged --with-ssh
redmine$ bundle install
redmine$ bundle exec rake redmine:plugins:migrate RAILS_ENV=production NAME=additionals
redmine$ bundle exec rake redmine:plugins:migrate RAILS_ENV=production NAME=redmine_git_hosting

Otherwise you can install Redmine by following the wiki : How to install Redmine.

If bundle command complains on Bitnami Stack, take a look at this.

(step 3) Create SSH Keys for user running Redmine


As we need to send commands over SSH in non-interactive mode, the SSH key must not have passphrase (-N '' argument). Also, it’s better to store SSH Keys outside of REDMINE_ROOT path so

root$ su - redmine
redmine$ mkdir ssh_keys
redmine$ ssh-keygen -m PEM -N '' -f ssh_keys/redmine_gitolite_admin_id_rsa

On Bitnami stack :

bitnami$ cd /opt/bitnami/apps/redmine/
bitnami$ mkdir ssh_keys
bitnami$ chgrp daemon ssh_keys
bitnami$ ssh-keygen -m PEM -N '' -f ssh_keys/redmine_gitolite_admin_id_rsa
bitnami$ chmod 640 ssh_keys/*

If you’re using Apache to run Redmine :

root# sudo -u www-data  mkdir -p            /var/www/redmine/ssh_keys
root# sudo -u www-data  ssh-keygen -m PEM -N '' -f /var/www/redmine/ssh_keys/redmine_gitolite_admin_id_rsa

Make sure SSH public key is created with key format PEM (use -m PEM parameter with ssh-keygen).

You will have to configure the plugin to point to this path.

(step 4) User running Redmine must have RW+ access to gitolite-admin


Assuming that you have Gitolite installed, add this in gitolite.conf file :

repo    gitolite-admin
  RW+                            = redmine_gitolite_admin_id_rsa

Otherwise you can install Gitolite (v3) by following this (this will automatically set the line above) :

Server requirements:

  * any unix system
  * sh
  * git 1.6.6+
  * perl 5.8.8+
  * openssh 5.0+
  * a dedicated userid to host the repos (in this document, we assume it
    is 'git'), with shell access ONLY by 'su - git' from some other userid
    on the same server.

Steps to install:

  * login as 'git' as described above

  * make sure ~/.ssh non-existent

  * make sure **Redmine SSH public key** we've just created (step 3) is available at $HOME/redmine_gitolite_admin_id_rsa.pub

  * add this in ~/.profile

        # set PATH so it includes user private bin if it exists
        if [ -d "$HOME/bin" ] ; then
          PATH="$PATH:$HOME/bin"
        fi

  * run the following commands:

        root$ su - git
        git$ mkdir $HOME/bin
        git$ source $HOME/.profile
        git$ git clone git://github.com/sitaramc/gitolite
        git$ gitolite/install -to $HOME/bin
        git$ gitolite setup -pk redmine_gitolite_admin_id_rsa.pub

(step 5) Gitolite must accept hook keys


root$ su - git
git$ vi (or nano) .gitolite.rc

## Look for GIT_CONFIG_KEYS and make it look like :
GIT_CONFIG_KEYS  =>  '.*',

## Enable local code directory
LOCAL_CODE       =>  "$ENV{HOME}/local"

## then save and exit

(step 6) Configure sudo


As root create the file /etc/sudoers.d/redmine and put this content in it :

Defaults:redmine !requiretty
redmine ALL=(git) NOPASSWD:ALL

Then chmod the file :

root# chmod 440 /etc/sudoers.d/redmine

(step 7) Add Gitolite server in known_hosts list


Make sure that Redmine user has Gitolite server in his known_hosts list. This is also a good check to see if Gitolite works.

It should not ask you for a password.

Also the SSH config file for Redmine user (<redmine user home>/.ssh/config) is not needed anymore! Remove it if exists!

root$ su - redmine
redmine$ ssh -i ssh_keys/redmine_gitolite_admin_id_rsa git@localhost info
# accept key

You should get something like that :

hello redmine_gitolite_admin_id_rsa, this is gitolite v2.3.1-0-g912a8bd-dt running on git 1.7.2.5
the gitolite config gives you the following access:
    R   W  gitolite-admin
    @R_ @W_ testing

Or

hello redmine_gitolite_admin_id_rsa, this is git@dev running gitolite3 v3.3-11-ga1aba93 on git 1.7.2.5
    R W  gitolite-admin
    R W  testing

(step 8) Install Ruby interpreter for post-receive hook


Our post-receive hook is triggered after each commit and is used to fetch changesets in Redmine. As it is written in Ruby, you need to install Ruby on your server. Note that this does not conflict with RVM. Ruby 2.5 at least is required for the hooks.

root$ apt-get install ruby
# or
root$ yum install ruby

(step 9) Finish installation - Configuration


The plugin is now installed, you can restart Redmine :)

But you must set some additional settings :

  1. Enable Xitolite repositories in Administration -> Settings -> Repositories

  2. Configure plugin settings in Administration -> Redmine Git Hosting, specially :
    • SSH Keys path
    • Temp dir path (to store GitoliteAdmin repository)
    • Access urls (SSH, HTTP, HTTPS)
    • Hooks url (This url will be called by our Gitolite hook to trigger repository view refresh so be sure it’s callable)
    • Hooks install (This may overwrite your existing Gitolite hooks)
  3. Check your installation in Administration -> Redmine Git Hosting Config Checks tab.

  4. Set some permissions on Administration -> Roles page, particularly if you want users to be able to create SSH keys (see below).

Before configuring the plugin you should take a look at this : Repositories Storage Configuration Strategy.

If you’re using a Bitnami Stack (again) : you must properly configure the temp directory. Here’s how.

(step 10) Add your SSH Keys


Repositories access are based on Redmine project’s memberships and members’s roles : you must add users with the adequate role as project’s member to be able to clone/update repositories.

You’ll also need to configure roles’s permissions on Administration -> Roles page.

Unless you want to access your repositories exclusively via Smart HTTP, users will need to set a public key to connect via SSH.

To do this, open a browser, login to Redmine and follow the My Account link in the upper right-hand corner of the page then Add SSH keys link.

SSH Keys should be unique, that is, the keys you set in Redmine should not already exist in the Gitolite repo.

At this point, the plugin should work. If not, take a look here : Troubleshooting.

Let me know if it works ! (or not)