how to determine default GPG key ID?
jim at meyering.net
Mon Nov 7 15:54:35 CET 2011
Is there some way to make GPG print the default key ID
without actually signing something or having access to
a signature? Preferably without having to create a
temporary file, either...
I.e., this is the ID that gpg would use if I were to sign
something with no override. I.e., gpg may examine some
envvars (not sure about that) or some .gnupg/gpg.conf's local-user
definition. But even determining which .gnupg/gpg.conf file to
read is not trivial, since gpg's choice depends on envvars like
Currently in gnulib's maint.mk file, I do this;
gpg_key_ID ?= \
$$(git cat-file tag v$(VERSION) > .ann-sig \
&& gpgv .ann-sig - < /dev/null 2>&1 \
| sed -n '/.*key ID \([0-9A-F]*\)/s//\1/p'; rm -f .ann-sig)
which is ok, since we always have a GPG-signed tag on the release, and
from that we can determine the ID of the signing key. Even that could
be improved if there's a way to extract the signing key ID without having
to use a temporary file.
However, in some other contexts I've wanted to automatically
determine the default key ID, yet did not have a signature handy.
More information about the Gnupg-devel