3

Is it possible to extract userid from GPG public key?

I got public key only and want to know to whom it might belong. I find one possible workaround — to publish this information on keyserver — it decodes information and reveals it to public. But I'm not sure, I should do this.

Is it possible to extract userid using command line gpg?

4

Use gpg --list-packets [filename] to list all data packets, then grep for user IDs. For example:

$ gpg --export 0xDED9B508F4E10DB2 | gpg --list-packets | Egrep '^:user ID packet'
:user ID packet: "John Doe <john@example.org>"

An alternative would be to use pgpdump

$ gpg --export 0xDED9B508F4E10DB2 | pgpdump | Egrep '^[[:space:]]*User ID'
    User ID - John Doe <john@example.org>
0

The following will emit the "username < email >" field from the UID packet, without requiring regexes:

$ gpg --with-colons --list-keys 0xDED9B508F4E10DB2 | awk -F: '$1=="uid" { print $10 }'
blah <a@b>

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.