Query the default key via command line?

Werner Koch wk at gnupg.org
Fri Aug 31 10:03:07 CEST 2007

On Thu, 30 Aug 2007 14:08, immanuel.scholz at tu-dresden.de said:

> I am writing an application that accesses the "gpg" executable. How do I
> retrieve the current default key id via the command line?

No explicit way.  You may run a test encrytiopn, though.

> This is nasty and does not work under non-linux ;). So is there an
> option I didn't recognized to display the default key id (preferable the
> full-id)?

Use gpgconf from the gnupg package:

  $ gpgconf --list-options gpg
  Monitor:1:0:Options controlling the diagnostic output:0:0::::
  quiet:0:0:be somewhat more quiet:0:0::::
  Configuration:1:2:Options controlling the configuration:0:0::::
  default-key:0:0:use NAME as default secret key:1:1:NAME:::"5B0358A2
  encrypt-to:0:0:encrypt to user ID NAME as well:1:1:NAME:::"5B0358A2
  Keyserver:1:0:Configuration for Keyservers:0:0::::
  keyserver:0:0:use keyserver at URL:1:1:URL:::"hkp%3a//minsky.surfnet.nl
This is the suggested way to read out and change options in the gnupg
system.  The format of the output is described in detail in the manual
and the gpgconf man page.



Die Gedanken sind frei.  Auschnahme regelt ein Bundeschgesetz.

More information about the Gnupg-devel mailing list