Simply Display all Encryption Keys on a File?

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


On Mon,  4 Jul 2016 23:52, rfkrocktk at gmail.com 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}'
  9185878E4FCD74C0
  1D777619BE310D79

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


Shalom-Salam,

   Werner

-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.
 /* Join us at OpenPGP.conf  <https://openpgp-conf.org> */




More information about the Gnupg-devel mailing list