12

I have multiple OpenPGP keys that I am managing with GPG. The problem is, they have the same user ID and the same e-mail address. How do I tell GPG the difference when I am, say, encrypting a file?

fouric
  • 4,498
  • 13
  • 36
  • 68

1 Answers1

12

You can always use a key ID instead of a user ID. For example, for encrypting a message to my newer key:

gpg --encrypt --recipient A4FF2279

In case of ambiguous key IDs, you might need to use a longer id or the full fingerprint.

Jens Erat
  • 4,993
  • 7
  • 31
  • 37
  • 2
    But why doesn't gpg warn me about the ambiguity if I just use the email address test@example.com in `gpg --recipient someone@example.com --local-user test@example.com --armor --sign --encrypt --verbose test.txt` ? pgp just use the first one found. – schemacs Jan 11 '20 at 11:28
  • yes, definitely a WTF from me. This has to rank as one of the dumbest decisions in gpg. Yes just silently encrypt with an unexpected key only and finding this when you decrypt sometime in the future (now I can't imagine what could go wrong there)... – Amos Folarin Sep 28 '22 at 19:12