6

I have the following script:

#!/bin/sh -e
PWD="supersecretpassword"
file="/backup/2do/example.txt"
echo before
echo $PWD | gpg --passphrase-fd 0 -c $file
echo after

The scripts works perfectly fine if executed manually, but simply stops working when the gpg line is performed when performed as crontab.

GPG shows:

gpg: cannot open `/dev/tty': No such device or address

I'm grateful for any suggestions!

Solution: add --no-tty to GPG

MrG
  • 289
  • 3
  • 10

3 Answers3

9
/usr/bin/gpg --no-tty --passphrase-file /home/vouuuuuuuuu/settings/passfile.txt --decrypt-files /home/juhuuu/dirname/*.gpg;
  • works fine now thank to --no-tty
  • before in cron job log gpg: cannot open/dev/tty': No such device or address`
  • so it could not execute before, now is fine!
chicks
  • 3,793
  • 10
  • 27
  • 36
Maris
  • 91
  • 1
  • 1
3

Add -vv to the gpg command to see more output. It might have to do with a missing ~/.gnupg though.

Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84
  • 2
    Thank you, that pointed me into the right direction: --no-tty – MrG Oct 14 '10 at 10:37
  • 2
    This is a good troubleshooting step as advice for everyone, but it seems that for a lot of people the real solution is `--no-tty` so this accepted answer could be improved if you turn the suggestion of a missing `~/.gnupg` into a list and add `--no-tty` as a second item on that list. – greggles Dec 14 '17 at 15:31
2

To resolve this problem just add the "--no-tty" option to your gpg command line. answer was taken from a cached google page

blades
  • 21
  • 1