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
And download Gitosis (clone it from its Git repository)
(also available from https://github.com/res0nat0r/gitosis)
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.
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:
This will generate public and private keys on our user folder, we need the public one, at “/home/usuario/.ssh/id_rsa.pub” on Linux or at “/Users/usuario/.ssh/id_rsa.pub” 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:
We setup Gitosis with our user as admin (giving it our public key path that in our example is at “/tmp/id_rsa.pub”)
And to finish we mark “post-update” as executable for all users.
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.
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 myserver.com by your own server)
and now we can open gitosis config file to add some repositories permissions
we’ll add “montes” repository as writable
and save and 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
and our first push!
and we are finish!