how to find the keygrip of a key

Werner Koch wk at
Tue Jan 5 08:51:22 CET 2010

On Tue, 5 Jan 2010 01:18:11 -0500, silly8888 wrote:

> I have a gpg key that I would like to add to gpg-agent using the
> gpg-preset-passphrase. I understand that gpg-preset-passphrase expects
> me to provide the keygrip the key but I cannot see how to find it. The
> key is an ordinary gpg key, nothing to do with gpgsm. Any help would

As of now gpg uses the gpg-agent only for passphrase caching.  That
does also mean that there is no keygrip.  Instead you use the
fingerprint of the key.  Usually the fingerprint of the primary key is
sufficient for almost all gpg actions.  However here we need to use
the fingerprint of the actual subkey; use this command to show it:

  $ gpg2 --fingerprint --fingerprint alpha at
  pub   1024D/68697734 1999-03-08
        Key fingerprint = A0FF 4590 BB61 22ED EF6E  3C54 2D72 7CC7 6869 7734
  uid                  Alfa Test (demo key) <alfa at>
  uid                  Alpha Test (demo key) <alpha at>
  uid                  Alice (demo key)
  sub   1024g/46A871F8 1999-03-08
        Key fingerprint = 3B3F BC94 8FE5 9301 ED62  9EFB 6AE6 D7EE 46A8 71F8
Thus for the decryption key you would use 

  $ echo abc | gpg-preset-passphrase \
          --preset 3B3FBC948FE59301ED629EFB6AE6D7EE46A871F8



Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

More information about the Gnupg-users mailing list