2

Let's say I have PGP key with two UIDs (personal and for work). I want to use this key for signing Git commits.

How can I use one UID for personal projects and the other one at work?

Also it seems to me when I export public key explicitly with email of one UID, the resulting public key still contains both UIDs. Is there some way to limit the contained UIDs to that mentioned in export command?

1

Both UIDs are signed by the key, and the public part of the key is, well, public. Therefore it does not really make sense to use only one of the UIDs to sign something. You sign with the private key, the same private key which signed both UIDs (that's how you verify that something came from that UID).

You can of course make two copies of your ~/.gnupg directory (or the equivalent on MS Windows) and run:

gpg --edit-key <key>
gpg> deluid 1

On one copy and

gpg --edit-key <key>
gpg> deluid 2

On the other. And use one copy on your personal machine and another on the work machine. The resulting signatures from both would be absolutely the same, and, moreover, if you upload both to a keyserver it will likely merge the UIDs once again.

The only real advantage would be that a person with access to your work machine would not know your personal email. And vice-versa. (All that given that you do not upload the public key to a keyserver of course).


All that said, I'm pretty confident you are after two keypairs (or even keychains): one for work matters and another for personal matters.

If you need badly the separation between work and personal projects, two keyparis are definitley the way to go. And managing two keypairs/keychains instead of one isn't a big overhead for GPG or even key backups.

1
  • But even the encryption key is signed by my key. It doesn't seems to me as a reason for having things public necessarily; The thing is I don't want my work email to be flying around the world. Thank you for the suggested workflow, I'll give it try – Mailo Světel Nov 23 '16 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.