Updating the gitolite admin’s public key

In a situation where the admin of a gitolite server needs to use a new pair of ssh keys, the obvious challenge is to make the necessary changes in the gitolite system to update the admin’s new public key.

First up, ssh into the gitolite server. You can do this using your new pair of ssh keys.

ssh gitolite-user@gitolite-server

Doing this will not only add the gitolite server to your known hosts, but also, create a terminal to run a few commands on the gitolite server.
Once you’ve managed to start an ssh session, open another terminal and send across your public key:

scp ~/.ssh/id_rsa.pub gitolite-user@gitolite-server:admin@new.pub

you can use anything instead of admin@new.pub. We’ll change it later anyways. The last command would’ve sent across your public ssh key to the gitolite server. Now go to your ssh terminal, and verify the same using ls. You need to rename the new public key you just sent across to have the exact same name as your previous admin public key. So if the previous admin public key was named, git-admin.pub, then you’ll need to do the following:

mv admin@new.pub git-admin.pub

It would be wise to backup the old admin public key, just in case it’s in the same folder as your new key.

Once you’ve done this, all you need to do is run the gl-setup script using the new key. I’m assuming that the bin folder, having the gitolite scripts, is on the system $PATH.

gl-setup git-admin.pub

That’s it. This should have successfully updated the gitolite admin’s public key. You can verify the same on the machine [with the new admin key], by cloning the gitolite-admin repository:

git clone gitolite-user@gitolite-server:gitolite-admin.

NOTE: Please don’t confuse this writeup with adding a new ssh key for the admin gitolite user, so that he/she can access the gitolite repositories from a separate machine. This writeup is specifically meant to cater to the situation wherein you need to set up the gitolite admin functionality using a new ssh key pair. This situation can arise from losing old admin keys, or, moving to a different machine.


4 thoughts on “Updating the gitolite admin’s public key

  1. Why should the new key have the same name as the previous key? Maybe the question should be how to rename the admin key?

    • i don’t think there’s a binding need to have the same name. this post only talks about how to replace/update an older pair of keys. you can use any name for your public/private key files.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s