GIt Daemon and Access Control for Multiple Repos

git

Here is the situation, I have a folder named git which contains various –bare git repositories. This is on my server which is CentOS 5. My personal computer at home is a Windows XP.

I want to push my local repositories to my server using an account on a per-repository bases. I've been searching for hours with no luck. Here is what I've done which came the closest.

I ran a daemon at my server by typing:

git daemon --verbose --base-path=/path/to/git/parent/folder --export-all

I then use TortoiseGit to push at the address: git://myserver.com/project and I get this from the daemon:

Connection from XX.XX.XX.XX Extended
attributes (22 bytes) exist
Request
receive-pack for '/project'
'receive-pack': service not enabled
for '/path/to/git/parent/project'
[XXXX] Disconnected (with error)

I used –enable=receive-pack and successfully push my local repository to the server but the result was not what I wanted: namely, to login in as a user. Receive-pack enables everyone to anonymously push to the server.

I've searched for hours but I cannot find how to configure accounts independently for each repository. I have read various articles saying something about SSH but I'm not sure if this is what I want. As far as I know, SSH is to securely connect to my server by logging in to a linux account at the server (i.e. root, userA etc.) And that is not what I want.

Take SVN for example, with subversion you can create a .htpasswd file with the accounts you want only for that specific repository. Is there a similar way with Git?

Thank you.

Best Answer

Check out gitosis which is a git repository hosting application. Quoting the description from the Debian package of gitosis:

This package aims to make hosting git repositories easier and safer.
It manages multiple repositories under one user account, using SSH
keys to identify users. End users do not need shell accounts on the
server; they will talk to one shared account that will not let them
run arbitrary commands.

You can find the gitosis source at http://eagain.net/gitweb/?p=gitosis.git

Documentation on how to set it up: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

I'm very happy with gitosis, we're using it at the grml project (http://grml.org/) with more than 100 repositories and it works fine without any problems.