How to use GnuPG with --passphrase?
Solution 1:
In GnuPG, options must preced commands, thus the --passphrase
option must come before --symmetric
.
Regarding the pin entry window, that pops up anyway (although you use --passphrase
), you're probably already using GnuPG 2, which requires --batch
to be used together with --passphrase
. From the man pages:
--passphrase string
Use string as the passphrase. This can only be used if only one
passphrase is supplied. Obviously, this is of very questionable
security on a multi-user system. Don't use this option if you
can avoid it. Note that this passphrase is only used if the
option --batch has also been given. This is different from
GnuPG version 1.x.
Be aware that on multi user systems all other users will be able to read your command line, and thus also the passphrase while GnuPG is executed. Better use one of the other --passphrase-*
options instead to read from a file or pipe.
Solution 2:
If gpg --version
reports v2, you need to add the --batch
option.
Based on the syntax output you're probably using v1, in which case you want:
gpg --passphrase PASS -c --no-use-agent FILE
Note that the order of options is not important; however, any file needs to be the last argument.