How to encrypt and sign with different keys

Robert J. Hansen rjh at
Mon Jul 18 23:02:32 CEST 2016

> I am struggling with GPG command line that will encrypt file with key A
> and sign it with key B. Any help would be appreciated. Also, is there a

ID-A is the certificate ID for A, ID-B is the certificate ID for B.

gpg --recipient ID-A --local-user B --encrypt --sign filename.txt

> way to provide the password for the signing key in the command line?

Please don't.  Doing things this way sort of destroys the purpose of a
passphrase.  Remove the passphrase from the certificate instead.

More information about the Gnupg-users mailing list