The script below used to work on Mac OS X, but, since moving it to Ubuntu, it doesn't seem to read from the password file at all. Even when I run it from the command line, no matter what I do, I get a popup prompt asking me for the password. As this will run via cron, I don't want this to happen... I want it to read the password from the file with no prompt. To note, I did try using passphrase-fd and passphrase-file, neither of which worked...
#!/bin/sh
p=$(<pass.txt)
set -- $p
pass_phrase=$1
destination="/var/www/decrypted"
cd /var/sl_bin/
for FILE in *.pgp;
do
FILENAME=${FILE%.pgp}
gpg --passphrase "$pass_phrase" --output "$destination/$FILENAME" --decrypt "$FILE"
rm -f $FILE
done
gpg caches the passphrase used for symmetric encryption so that a decrypt operation may not require that the user needs to enter the passphrase.
Open the terminal application. Get a list of GPG keys by running the gpg --list-keys command. Run gpg --edit-key your-key-id command. At the gpg> prompt enter the passwd to change the passphrase.
For me the simplistic way to check the passphrase is to use gpg --passwd shorthand. It tries to change the passphrase and the step is to confirm the old passphrase, and then you can click 'cancel' on the new passphrase prompt and this keeps the passphrase intact. which is even better.
This works:
gpg --no-use-agent --batch --passphrase-file pass.txt --output kkkk.tar.bz2 --decrypt kkk-data.tar.bz2.gpg
The --passphrase-file
option seems to be broken / not honored. I had to use --passphrase-fd 0
instead, like so:
cat .password | gpg --passphrase-fd 0 --output foo --decrypt foo.gpg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With