GPG Passphrase on the command line

Johan Wevers johanw at
Sun Sep 25 00:43:44 CEST 2005

Low, Claudia wrote:

>  Is there an option, eg. --passphrase, that I can use so that I can
>pass the passphrase in the command line when doing a signing, symmetric
>encryption or decryption? Without this option, I will be prompted on the

No, you'll have to pipe it through a file descriptor with --passphrase-fd.
But with the echo command it can be done on a commandline too on fd 0:
echo password | gpg --passphrase-fd 0 --decrypt / --encrypt.

For some reasons I don't completely understand the GnuPG developers feel
this is less insecure than a normal commandline (you're certainly not the
first to ask this...).

>  In my program, I can only use command line to execute the commands. I
>am not able to pass in the passphrase from a file (using file
Piping doesn't necessarily require a file. I don't know what language your
application is in, but for C or C++, see pipe(), dup2() and fork().

ir. J.C.A. Wevers         //  Physics and science fiction site:
johanw at   //
PGP/GPG public keys at

More information about the Gnupg-users mailing list