How to encrypt and sign with different keys

Daniele Nicolodi daniele at
Mon Jul 18 23:03:52 CEST 2016

On 7/18/16 2:49 PM, Dashamir Hoxha wrote:
> On Mon, Jul 18, 2016 at 9:40 PM, dom at <mailto:dom at>
> <dom at <mailto:dom at>> wrote:
>     I am struggling with GPG command line that will encrypt file with
>     key A and sign it with key B.

You can select the key for signing with the --local-user option and the
key for encrypting with the recipient option.

>     Also, is there a way to provide the password for the signing key in
>     the command line? 
> Try appending this to the command: `--passphrase-fd=0 <<< thepassphrase`

That's most definitely the wrong syntax.

>     I am trying to automate encrypting files.

If you want to automate signing consider exporting a signing subkey
without a passphrase. The passphrase would have to be stored along with
the key anyhow.

> Consider also using and customizing `egpg`:
>  -
>  -

Or better not.


More information about the Gnupg-users mailing list