I recently had to replace a hard drive in my laptop. While this was a great opportunity to clean things up and have a fresh machine, it turn into a huge, huge time-sink :(
We’ve started using git internally and for our “primary” git repository we’re using gitosis. Normally gitosis makes things “just work” so well that the fact that the server is debian and not even on the domain is completely transparent to the developers. As you may know, git uses ssh to handle communication. In order to do that, you generate a key pair and share your public key with the git server which it uses to authenticate you (in addition to your password).
The problem is that I “lost” my key pair that was originally provided to gitosis for authentication. Even though I could still get my public key from the server, I couldn’t re-generate the same private key… The only way gitosis supports addition/changing of keys is through the gitosis-config repository. You actually configure gitosis by pulling it’s configuration to your local machine via git, check-in the changes and push it back to the server. Every time you push, a post-update trigger fires to do some gitosis magic.
Well, since this is a new process and I’m the only one who knows diddly about gitosis, I was the only person able to change the gitosis configuration… yeah, I’m that dumb. The problem was that no matter what I tried, I could not get gitosis to accept a new key for my account; and I tried a lot of different things.
What finally worked was directly editing the authorized_keys file (which you’re not supposed to ever do), and change the existing key to my new public key. I then changed the key in the gitosis-admin repository and was able to push that back up to the server so that it would properly reconfigure itself (and also not break in the future due to a stale public key getting pushed).
Hopefully that will help someone else out there, I lost the better part of my day : \
Tags: gitosis, git, ssh