There are many options for having a private remote git repository on the internet like for example Github, that is free for public repositories but not for private ones.

We can pay for one of this services or if we already have a server for our web, why not using it also for our repositories? Here is where Gitosis is going to help, we’ll be able to have unlimited private repositories with group access control.

Installing Gitosis on Debian

Although there are multiple tutorials through the internet for doing this, I haven’t been able to find one that covers the whole process. The next steps are the result of testing multiple solutions and applying the best mix.

1. Install python-setuptools and download Gitosis

On the server

aptitude install python-setuptools

And download Gitosis (clone it from its Git repository)

cd /data/temp
git clone git://

(also available from

2. Install gitosis

Be careful with “–home /data/git” parameter, here you must set git user’s home, that is where repositories will be written.

python install
adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /data/git git

3. Generate a RSA public key on our local computer

After installing Gitosis on the server, now we need to generate a public key on our local development computer.

On Linux and Mac:

ssh-keygen -t rsa

This will generate public and private keys on our user folder, we need the public one, at “/home/usuario/.ssh/” on Linux or at “/Users/usuario/.ssh/” on OSX.

4. Install our public key on the server

Back to the server and having uploaded our public key (by ftp for example).

We will need “sudo” that is not installed by default on Debian:

aptitude install sudo

We setup Gitosis with our user as admin (giving it our public key path that in our example is at “/tmp/”)

sudo -H -u git gitosis-init < /tmp/

And to finish we mark “post-update” as executable for all users.

sudo chmod 755 /data/git/repositories/gitosis-admin.git/hooks/post-update

5. Bonus track: Redmine or any web front for Git on the server.

If we are going to use Redmine or any other web viewer for git repositories we’ll need to include apache’s user “www-data” in git’s group so it’ll be able to access to our repositories.

usermod -a -G git www-data

6. We are ready, our first push

And we only need to clone the Gitosis config repository and we will be able to setup permission groups. (change by your own server)

git clone [email protected]:gitosis-admin.git

and now we can open gitosis config file to add some repositories permissions

cd gitosis-admin
vim gitosis.conf

we’ll add “montes” repository as writable

  [group gitosis-admin]
  writable = gitosis-admin montes
  members = [email protected]

and save and push

git commit -a -m "Giving write permission on montes repository for gitosis-admin group"
git push

With this we have given write permissions on “montes” repository (that still doesn’t exist) to our user [email protected] that is the owner of the public key we generated before.

We only have to create the repository on our local computer

cd ..
mkdir montes
cd montes
git init

Add remote

git remote add origin [email protected]:montes

and our first push!

git add .
git commit -a -m "Primer commit!"
git push miservidor master

and we are finish!