Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to decrypt a file using the following command within a unix shell prompt:

gpg --passphrase-file /path/to/passphrase/file --output /path/to/output/dir/full_db_restore --decrypt full_db_backup_current.tar.gpg

I get the following error when running the command above:

gpg: 3DES encrypted data
gpg: problem with the agent: No pinentry
gpg: encrypted with 1 passphrase
gpg: decryption failed: No secret key

I have verified that pinentry is installed. I'm not sure if pinentry is the issue. I have a feeling it might be with the "No secret key" error. Any help would be appreciated.

share|improve this question

migrated from May 5 '11 at 1:03

This question came from our site for professional and enthusiast programmers.

good question but I think it should be moved to superuser, because that's not a programming related question. – Heisenbug May 3 '11 at 14:56

I've discovered a solution to this.

/usr/bin/gpg --no-tty --batch --passphrase-file /path/to/passphrase/file --output   \
/path/to/output/dir/full_db_restore --decrypt full_db_backup_current.tar.gpg

The only difference is that I've added --no-tty and --batch options. After logging onto my unix server, I switch users from userA to userB. I'm assuming that because I switch users, there was an error. I'm not sure if this is the write solution as the options mentioned above are used when calling the command from a shell script. Any additional information would be greatly appreciated. Thanks in advance.

share|improve this answer

You must to use this command:

    gpg --batch --passphrase-fd 1 --passphrase-file /path/to/passphrase/file  
    --output /path/to/output/dir/full_db_restore full_db_backup_current.tar.gpg

--batch: is used in scripts for non-interactive mode (no asking);

--passphrase-fd 1 together with --passphrase-file: to read the passphrase from a file.

If you use only --passphrase-file on *nix it will not work.

Good luck.

share|improve this answer

You must log in to answer this question.