gpg: WARNING: unsafe permissions on configuration file
gpg: WARNING: unsafe enclosing directory permissions on configuration file/home/david/.gnupg/gpg.conf'
gpg: external program calls are disabled due to unsafe options file permissions
This means that your
~/.gnupg/gpg.conf has unexpected permissions for the user you are running as, like write access to "others", another user or the executable bit. This file should always for security reasons only be readable and writable by the user, and no one else:
$ ls -l ~/.gnupg/gpg.conf
-rw------- 1 braiam braiam 7890 Jul 8 18:51 .gnupg/gpg.conf
Yours probably has different user or permissions. Check them out using
ls -l ~/.gnupg/gpg.conf. To fix this is simple enough:
chown $(whoami):$(whoami) ~/.gnupg/gpg.conf ## if this fails read at the bottom
chmod 600 ~/.gnupg/gpg.conf
If some of the commands fails, or you keep getting the error message you mentioned after following these instructions, you should delete the
~/.gnupg directory, because it cannot be trusted anymore.
rm -r ~/.gnupg/gpg.conf ## If this fails, use sudo
You can then try to run
gpg command with the same user that is going to run the script, this way your user with create
~/.gnupg directory with appropriate permissions.