Gitolite: add users and multipe keys per user

Figuring out why I was having trouble adding a user was pretty upsetting so I will share the experience and hope no one else runs into it also.

  1. Create the ssh key for user
    • ssh-keygen -t rsa
    • Do no try and use the -f option. I tried using the -f figuring it’d save me some time but using the -f prevents it from working correctly.  stackoverflow
  2. Copy public key to where you have gitolite-admin rights
    • scp id_rsa.pub mfang@client:/home/mfang
    • id_rsa.pub should be the file created from the ssh-keygen command from Part 1
  3. On computer (client) with gitolite-admin rights
    • mfang@client~$ cp id_rsa.pub gitolite-admin/keydir/mfang.pub
    • mfang@client~$ cd gitolite-admin
    • mfang@client~/gitolite-admin $ git add keydir/mfang.pub
    • mfang@client~/gitolite-admin $ git commit -m ‘Add user “mfang”‘
    • mfang@client~/gitolite-admin $ git push

Now say you use a laptop and a desktop both with usernames of mfang. How do you setup Gitolite to handle multiple keys for one user. There’s actually a recommendation in the documentation that of course you haven’t read.

The simplest and most understandable is to put their keys in different subdirectories, (alice.pub, home/alice.pub, laptop/alice.pub, etc).

I believe the point of doing it the above way is that in the conf/gitolite.conf file, it will recognize that user mfang is associated with all those keys.

Advertisements
This entry was posted in Git and tagged , , , , . Bookmark the permalink.

One Response to Gitolite: add users and multipe keys per user

  1. gloriphobia says:

    Actually what is written below that link is really straightforward. If bob has three public keys, you can call them bob@1.pub, bob@2.pub, bob@3.pub and then in the conf file you just write bob and then it will apply to all three keys.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s