Bash – user GPG key not able to be used by SUDO

bashduplicitygpgsudo

I created a script that runs duplicity to backup files I have on a VPS,and uses a GPG key that I generated as a user.

When I try and run this script as SUDO I get:

GPGError: GPG Failed, see log below:
===== Begin GnuPG log =====
gpg: C7B2Y6DO: skipped: public key not found
gpg: [stdin]: encryption failed: public key not found ===== End GnuPG log =====

Now I realize why this is (because it's not SUDO's key, it's the users key) but before I go and re-generate a key for SUDO is it possible to have sudo use the users key?

Not really important but the script is modeled off a combination of these three sites:
http://www.cenolan.com/2008/12/how-to-incremental-daily-backups-amazon-s3-duplicity/

http://www.randys.org/2007/11/16/how-to-automated-backups-to-amazon-s-s3-with-duplicity/

https://help.ubuntu.com/community/DuplicityBackupHowto

Best Answer

Solution: Added the following to the bash script:

HOME=/home/user/

Fin