0

I have a bash script that decrypts files using GPG. The script works perfectly when executed manually from the terminal, but when I run it through cron, I get the following error: gpg: decryption failed: No secret key

What I’ve done so far: Verified that my GPG keys are correctly configured. Running gpg --list-secret-keys displays the expected keys. The script runs without issues when executed manually: ./decrypt.sh

My crontab entry looks like this:

/path/to/decrypt.sh

The cron job runs in a different environment, and it may not have access to the GPG keys. The local gpg-agent might not be available in the cron context

Added GPG_TTY explicitly in the script:export GPG_TTY=$(tty)

0 Answers0