6

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?

2 Answers 2

5

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 <[email protected]>"

An alternative would be to use pgpdump

$ gpg --export 0xDED9B508F4E10DB2 | pgpdump | Egrep '^[[:space:]]*User ID'
    User ID - John Doe <[email protected]>
2

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>

You must log in to answer this question.

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