I have four OpenPGP keys, I need to sign the Ubuntu Code of Conduct with a specific OpenPGP key. How do I make one of the OpenPGP key is default so I can sign the code with that key?


Signing the Ubuntu Code of Conduct

The general signing procedure is described in Ubuntu's GnuPG how-to. It boils down to performing a clear-text signature of a text document:

gpg --clearsign UbuntuCodeofConduct-2.0.txt

Selecting a Specific Key for Signing

To sign using a specific key, you need to tell GnuPG which one to use. From man gpg:

          Make a clear text signature.  The content in a  clear  text
          signature is readable without any special software. OpenPGP
          software is only needed to  verify  the  signature.   Clear
          text signatures may modify end-of-line whitespace for plat-
          form independence and are not intended  to  be  reversible.
          The  key to be used for signing is chosen by default or can
          be set with the --local-user and --default-key options.


   --local-user name
   -u     Use  name  as  the  key to sign with. Note that this option
          overrides --default-key.

The changed clearsign command form above is:

gpg --local-user [key-id] --clearsign UbuntuCodeofConduct-2.0.txt

Setting a Persistent Default Key

This just modifies the behavior for the current call of GnuPG. To set a default key (which can still be overridden using --local-user), set default user [key-id] in ~/.gnupg/gpg.conf instead.

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.