Shell – gpg asks for password even with –passphrase

gpgshell-script

I expect the following command to extract the gpg file without asking for password:

  gpg --passphrase 1234 file.gpg

But it asks for the password. Why?

This also have the same behavior:

  gpg --passphrase-file passfile.txt file.gpg

I use Ubuntu with gnome 3, and remember that it was working in Fedora

Best Answer

I am in your exact same boat (it worked on Fedora but not Ubuntu). Here is an apparent work around I discovered:

echo your_password | gpg --batch --yes --passphrase-fd 0 your_file.gpg

Explanation: Passing 0 causes --passphrase-fd to read from STDIN rather than from a file. So, piping the passphrase will get --passphrase-fd to accept your specified password string.

Related Question