Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a ssh key to gitolite server without using gitolite-admin? [closed]

I want to add a ssh key to my gitolite server from a new workstation. I can't do it through gitosis-admin, because I can't clone it, and I don't have access to my previous laptop containning the ssh-key with which I installed gitolite.

How can I add my new key to gitosis-admin/keydir without cloning gitosis-admin?

Thanks

like image 687
jul Avatar asked Jan 07 '13 16:01

jul


1 Answers

The "Don't panic" page can help (for gitolite V3, not the old obsolete gitosis):

lost admin key/access

If you lost your gitolite admin key or access, here's what you do. We'll assume your username is 'alice'.

  • Make yourself a new keypair and copy the public key to the server as 'alice.pub'.
  • Log on to the server, and run gitolite setup -pk alice.pub.

That's it; the new alice.pub file replaces whatever existed in the repo before.

That would allow you to add keys using a clone of gitolite-admin repo, as you should.

That won't "reset" your gitolite.conf file, or anything in your gitolite-admin repo: it will complete the ~/.ssh/authorized_keys file.
It certainly have no effect on your existing repositories.

That being said, if a gitolite command seems too risky, you can try the second approach:


bypassing gitolite

You may have lost access because of a conf file error, in which case the above trick won't help. What you want is to make changes to the repo (or perhaps just rewind) and push that. Here's how to do that:

  • Log on to the server.
  • Clone the admin repo using the full path: git clone $HOME/repositories/gitolite-admin.git temp.
  • Make whatever changes you want -- add/replace a key, 'git revert' or 'git reset --hard' to an older commit, etc. Anything you need to fix the problem, really.
  • Run gitolite push (or possibly gitolite push -f). Note that's 'gitolite push', not 'git push'.

NOTE: gitolite does no access checking when you do this!

like image 61
VonC Avatar answered Sep 23 '22 17:09

VonC