corrupted secret keyring

David Shaw
Tue Jul 16 22:25:02 2002

On Tue, Jul 16, 2002 at 08:02:31PM +0000, Brian M. Carlson wrote:
> Foolishly, I imported that key pair that someone sent to the list some
> time ago, claiming that it didn't work for them. I said it worked just
> fine for me. Well, it doesn't. I was cleaning up my secret keyring
> (somehow, I have obtained about 20 other *secret* keys, none of them
> with public keys) and now that I have deleted them, I am unable to:
> export my secret keys
> delete keys from my public keyring
> I am able to:
> sign
> export public keys

It's not terribly elegant, but you can use gpgsplit (comes with 1.0.7
and later) to break your secret keyring into its component packets,
delete the evil key, and then reassemble.


1) cd ~/.gnupg ; mkdir temp; cd temp
2) gpgsplit ../secring.gpg
3) Find which of the "secret_key" packets is the bad one (run gpg on
   it to print out the key id) and delete it and the other packets
   that go along with it (i.e. delete everything until the next
4) cat * > newsecring.gpg

Then backup your current secring, and give newsecring.gpg a try.


   David Shaw  |  |  WWW
   "There are two major products that come out of Berkeley: LSD and UNIX.
      We don't believe this to be a coincidence." - Jeremy S. Anderson