Simply Display all Encryption Keys on a File?

Werner Koch wk at
Tue Jul 5 10:40:36 CEST 2016

On Mon,  4 Jul 2016 23:52, rfkrocktk at said:

> Is there a way to take a GnuPG 2 encrypted file and simply display the key
> ids that it was encrypted to? Obviously this probably won't work for
> --hidden-encrypt-to, but is there a shorthand way of doing this? I've tried
> using gpg2 --list-packets, but this attempts to decrypt the file first.

This should work:

  $ cat enc-2-keys-2.gpg \
     | gpg --no-options --no-default-keyring --keyring /dev/null \
           --batch --status-fd 1 2>/dev/null \
     | awk  '$1=="[GNUPG:]" && $2=="ENC_TO" {print $3}'

Unfortunately there is no --skip-decrypt option and thus you need to
use the above trick.  Works with all gpg versions.



Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.
 /* Join us at OpenPGP.conf  <> */

More information about the Gnupg-devel mailing list