Gitolite allows you to host Git repositories easily and securely.
It is also available on GitHub, where you can find the lastest update.
Add a git user and setup gitolite. id_rsa.pub is the public key file for the user who will have access to the gitolite-admin repo:
# useradd -m -U -r -s /bin/bash -d /srv/git git # su - git $ gitolite setup -pk id_rsa.pub
Add to your work-machine's
Host server HostName 192.168.12.2 User git ### IdentityFile specifies the private ssh-key Identityfile ~/.ssh/id_rsa
Do NOT add repositories or users directly on the server! You MUST manage the server by cloning the special gitolite-admin repository on your workstation:
$ git clone server:gitolite-admin
Ask each user who will get access to send you a public key. On their workstation generate the pair of ssh keys:
Rename each public key according to the user's name, with a .pub extension, like sitaram.pub or john-smith.pub. You can also use periods and underscores. Have the users send you the keys.
Copy all these *.pub files to keydir in your gitolite-admin repo clone. You can also organise them into various subdirectories of keydir if you wish, since the entire tree is searched.
Edit the config file (conf/gitolite.conf in your admin repo clone). See the gitolite.conf documentation (http://sitaramc.github.com/gitolite/admin.html#conf) for details on what goes in that file, syntax, etc. Just add new repos as needed, and add new users and give them permissions as required. The users names should be exactly the same as their keyfile names, but without the .pub extension
$ nano conf/gitolite.conf
Commit and push the changes them:
git commit -a git push
If you want to distinguish users with the same login (like username@server1, username@server2) you may want to do the following (for-3.04-1):
$user =~ s/(\@[^.]+)?\.pub$//; # baz.pub, firstname.lastname@example.org -> baz
$user =~ s/\.pub$//; # email@example.com -> baz@home
- update authorized_keys file (for example, by pushing into the gitolite-admin repository)