0

I have two private keys with the same UIDs in GnuPG, and would like to use the newer one in preference to the older.

When no key is specified, the default-key option takes care of this, but several of the Debian tools explicitly specify my email address as the UID to use, which makes gpg select the older key. I can work around this by explicitly specifying the key ID every time, but it is annoying over time.

How can I specify a preference order for available secret keys if multiple keys have the selected UID?

4
  • By duplicate UID, do you mean, the same email address? Or do you mean the same key hash?
    – aiootp
    Commented Sep 17, 2023 at 4:26
  • Same email address and name, because I moved from DSA1024 to RSA4096 at some point. The old key still exists and is still usable, and gpg prefers it for some reason. Commented Sep 17, 2023 at 4:28
  • Do you need the old key to be available to automated tools as well?
    – aiootp
    Commented Sep 17, 2023 at 4:34
  • It should remain available for decryption at least. I also sometimes (very seldom) create double signatures with both old and new keys, but that's an involved manual process anyway. Commented Sep 17, 2023 at 4:36

1 Answer 1

0

I'd recommend exporting the old key, saving it encrypted somewhere & only re-importing it when you need to use it for those manual operations.

It's also possible, and maybe more convenient, to remove the old key from the main system keyring & import it into another context using the homedir option. It would be used like this:

gpg2 --homedir <custom-manual-home-directory> <other-options> <other-inputs>

Before deleting the old key from the main keyring, make sure it's backed-up securely.

2
  • Both keys are smartcard keys, so using the old smartcard automatically reimports the old key. Commented Sep 17, 2023 at 4:50
  • @SimonRichter Mmm. Sorry, I don't know enough about smart cards to help much with that aspect. Add this detail to the question so someone with smartcard experience might drop by.
    – aiootp
    Commented Sep 17, 2023 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .