wiki:Give users access to gitolite repos

Version 8 (modified by enno, 3 weeks ago) ( diff )

--

Give users access to gitolite repos

All changes to your running gitolite instance are made on the checked out gitolite-admin repo. They come into effect as soon as you push them to the server

Create a new SSH key pair for every user or role

ssh-keygen -t ed25519 -f ~/.ssh/KEYNAME

Example:

ssh-keygen -t ed25519 -f ~/.ssh/mesechannel

This creates:

~/.ssh/mesechannel (private key)

~/.ssh/mesechannel.pub (public key)

Add the new public key to Gitolite

Clone the gitolite-admin repo if you haven't already:

git clone kokyou.dev:gitolite-admin

Copy the user key to the keydir

cd gitolite-admin
cp ~/.ssh/mesechannel.pub keydir/mesechannel.pub

Edit conf/gitolite.conf

repo airsituation
    RW+ = admin mesechannel
    R   = mesepackager

repo gitolite-admin
    RW+ = admin

Only admin can write to the gitolite-admin repo

Both admin and mesechannel can fully control the airsituation repo.

mesepackager can only read the airsituation repo

Push changes to effect your setup

Once you changed keydir/ and/or conf/, you must commit and push like this:

git add keydir/
git add conf/gitolite.conf
git commit
git push

After push, Gitolite applies changes automatically — no restart needed.

Edit local ~/.ssh/config

Host kokyou.dev
    User git
    IdentityFile ~/.ssh/admin
    IdentitiesOnly yes

Host gitolite-mesechannel
    HostName kokyou.dev
    User git
    IdentityFile ~/.ssh/mesechannel
    IdentitiesOnly yes

Host gitolite-mesepackager
    HostName kokyou.dev
    User git
    IdentityFile ~/.ssh/mesepackager
    IdentitiesOnly yes

SSH knows which key to use depending on which Host alias you reference.

Push an existing local project to Gitolite

From your project directory:

cd ~/projects/myproject
git remote add origin gitolite-mesechannel:airsituation
git push

In case you want to push as admin use

git remote add origin kokyou.dev:airsituation

Clone a repo using different users/keys

Example:

git clone gitolite-mesechannel:airsituation

or

git clone gitolite-mesepackager:some-other-repo

depending on which SSH identity you use.

back

Note: See TracWiki for help on using the wiki.