Cron GPG Scripts can't locate the Keyring
-
I made a basic script to encrypt everything contained in a specific directory as a test
gpg —batch —recipient 8A4YA9YC —encrypt —yes /directory/to/encrypt/* find . -name '.txt' -exec mv {} /home/datatransfer/company/archive/out/ \;
The key here isn't real.
If I run the script manually it works. If I try to run it with cron it errors with
encryption failed: No public key
.It clearly can't see the path to the key, so I tried to find a way to specify it.
gpg —batch --homedir /home/serviceaccount/.gnupg/pubring.gpg —recipient 8A4YA9YC —encrypt —yes /directory/to/encrypt/*
Same error:
encryption failed: No public key
-
You are running it manually as your user and in a cron as root.
-
@JaredBusch I'm running it as root in both instances to test
-
Alright I see one thing I did wrong was specify a file rather than a directory.
gpg —batch --homedir /home/serviceaccount/.gnupg/pubring.gpg —recipient 8A4YA9YC —encrypt —yes /directory/to/encrypt/*
has been changed to
gpg —batch --homedir /home/serviceaccount/.gnupg/ —recipient 8A4YA9YC —encrypt —yes /directory/to/encrypt/*
-
That seems to have fixed the issue