I have cron job running a script in the cron of "USER A" that encrypts many files in a loop using the gpg command below:
gpg --batch --cipher-algo AES256 --passphrase "PASSWORDISHERE" -c FILENAME
"USER A" has elevated permissions, can not be SSH'ed to, and is only logged in by normal users when needed. So, when I SSH in as myself (Bob), I can decrypt the encrypted files. However, when I "su -" over to USER A and try to decrypt I get the error below:
gpg: AES256 encrypted data can't connect to `/home/USERA/.gnupg/S.gpg-agent': No such file or directory gpg-agent: command get_passphrase failed: Operation cancelled gpg: cancelled by user gpg: encrypted with 1 passphrase gpg: decryption failed: No secret key
I have done a bunch of research and found many things relating to tty and pinentry. The only solution I found was to use
chmod o+rw $(tty), but this is not a good long term solution for me not to mention I don't want to use this method anyway. Does anybody have any better ideas?