I have two keys $FPR1 and $FPR2 in my secret keyring (identified by fingerprint,
and both with signing capability), listed in that order by 'gpg -K'. My
~/.gnupg/gpg.conf contains 'default-key $FPR2', however gpg 2.1.10 ignores the
option and selects the first available key, namely $FPR1, for signing
operations. I'm able to force it to select $FPR2 using --local-user:
echo test | gpg2 --local-user $FPR2 -a --sign
(But the manpage suggests that --default-key should work in the absence of
--local-user option.) However, while the command line option work, I can't seem
to be able to add it to the configuration file:
~$ echo local-user $FPR2 >>~/.gnupg/gpg.conf ~$ echo test | gpg2 -a --sign gpg: key specification '$FPR2' is ambiguous gpg: (check argument of option '--local-user') gpg: '$FPR2' matches at least: gpg: $FPR2 gpg: $FPR2
(Yes, the same fingerprint is listed twice. And there are no collisions in my
private keyring :-P.)
I also tried to add '--default-key $FPR2' as a command line option, but unless
--local-user this does not make gpg select that key.