I have two keys in my keyring:

jason@host $ gpg --list-keys
pub   1024R/B051EDBF 2017-11-27
uid                  realname <someone@somewhere.com>
sub   1024R/4C83269B 2017-11-27

pub   1024R/28FDD919 2017-11-27
uid                  anothername <anothername@somewhere.com>
sub   1024R/4C928D6B 2017-11-27

I can sign a file with it

jason@host $ gpg --sign example

And I can verify that signature

other@host $ gpg --verify ~jason/example.gpg

As the user "jason" how do I sign that file instead with the second key in the keyring?

(Note that I am using 1024 bit keys because they generate more quickly. This is POC work and will not be exposed to the internet.)


You specify a different default secret key. See section 1.2.1 of the GnuPG documentation.

gpg --default-key 28FDD919 --sign example

You can also change the default key in the GPG configuration file to make it persistent.

default-key 28FDD919

As a side-note, RSA 1024 is obsolete now days and is weak. 2048 is the recommended minimum.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.