Discussion:
PGP Encryption script runs from command line but not from cron job
(too old to reply)
Brian Huber
2003-08-04 00:55:42 UTC
Permalink
Please help!

I have a script that uses PGP command line 6.5.8 to PGP encrypt files and
ftp them to a remote host.

If I run the script from the command line it works perfectly, but as a chron
job the PGP encryption fails with "Cannot find the public key matching
userid" error. I've made sure my pubring.pkr is in the path , set the
PGPPATH directory in the script, and set all relevent permissions to 777 for
testing (the script, .pgp directory containing pubring.pkr).

My crontab looks like this:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/root/.pgp
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

#problem script HERE
50 * * * * root /root/scripts/./backup.sh


Any suggestions greatly appreciated. Thank You
Jeroen Geilman
2003-08-07 20:58:59 UTC
Permalink
Post by Brian Huber
Please help!
I have a script that uses PGP command line 6.5.8 to PGP encrypt files and
ftp them to a remote host.
If I run the script from the command line it works perfectly, but as a
chron job the PGP encryption fails with "Cannot find the public key
matching userid" error.
Then I would start by posting the *script* ...
Post by Brian Huber
I've made sure my pubring.pkr is in the path ,
That is not what the $PATH is for, the $PATH is only for *executables*.
Post by Brian Huber
set the PGPPATH directory in the script,
Sounds more like *this* should hold the location of your keys...

Again, without this magical "script" of yours there is NOTHNG to examine...
Post by Brian Huber
and set all relevent permissions to 777 for testing
(the script, .pgp directory containing pubring.pkr)
And where does the *security* of all this come in ?

Might as well forget about encryption then...

Don't do it "for testing"...do it *right* :

- script should have 700 perms, as it is only going to be run by root.
- pgp dir should have the perms the program set on it, probably also
restricted to the owner of the keys, 700
YOUR crontab...?

That is the *system* crontab, not your crontab.
Post by Brian Huber
#problem script HERE
50 * * * * root /root/scripts/./backup.sh
What is this "/./" ?

Try running a shell script FROM a shell, like so:

50 * * * * root /bin/bash /root/scripts/backup.sh
--
Jeroen Geilman

On KNode, thankfully...
Loading...