Jun 152011

You can use gitosis to allow people to collaborate on a project via git. Its a utility to allow read and write access based on SSH encryption keys. And you only need to create a single system account, not one for every contributor.

First, install gitosis:

apt-get install gitosis

Now you are ready to go with the user account gitosis. But if you want to use the system account git so that the git clone ... URLs are shorter, you have to set up this user on your own:

adduser --system --shell /bin/sh --gecos 'git repository hosting' \
  --group --disabled-password --home /home/git git

Now generate an SSH keypair from the user of YOUR local computer:

ssh-keygen -t rsa

then copy id_rsa.pub to the server, to /tmp for example. You can do this via scp ~/.ssh/id_rsa.pub SOME_USER@YOUR_SERVER_HOSTNAME:/tmp.
Now initialize gitosis with the new public key:

su git
gitosis-init < /tmp/id_rsa.pub

Now get the gitosis administration repository on your local computer, change the settings, commit and push them back to the server:

git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git
cd gitosis-admin
##  Now adjust `gitosis.conf` to your needs.
##  The names of members must correspond to the filnames in the subfolder gitosis-admin/keydir.
##  Enough for your needs should be the follwing example to add a new group *board* with write-
##  access to the repositories *Charta* and *templates* (will create the repos automatically):
cat << EOF >> gitosis.conf
[group board]
members = richard
writable = Charta templates
## now commit and push back
git add . && git commit && git push

Now you can push any git repository to the remote repositories Charta and templates:

# In any local git repository run:
git remote add origin git@YOUR_SERVER_HOSTNAME:Charta.git
git push origin master


VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
Install Gitosis on Debian Squeeze, 10.0 out of 10 based on 1 rating

Related Posts:

  One Response to “Install Gitosis on Debian Squeeze”

  1. Hey!

    Thank you very much – this was the most helpful gitosis tutorial that I could find out there. I was able to set up gitosis in less than 20 minutes with it (despite I expected it to be quite a pain judging from stories of other people). The only thing which remained a little bit unclear to me was, if a group has other effects besides mapping users to repos and what I have to do to add a completely new user.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>