creating:
GNUPGHOME=${GNUPGHOME?'need path for new gnupg home dir'}
GPG_PASS_PHRASE=${GPG_PASS_PHRASE-passphrase}
# refuse to overwrite existing
if [ -e "$GNUPGHOME" ] ; then
echo "$GNUPGHOME already exists!"
exit 1
fi
# create the directory, set permissions
mkdir -pv "$GNUPGHOME"
chmod 700 "$GNUPGHOME"
# create a secret key
export GNUPGHOME
cat << EOF | gpg --batch --gen-key
Key-Type: RSA
Name-Email: [email protected]
Passphrase:$GPG_PASS_PHRASE
EOF
using: make sure GNUPGHOME
env var is set, and add --passphrase=$GPG_PASS_PHRASE --batch --pinentry-mode loopback
to gpg options
ex echo "hello" | gpg --armor --sign --passphrase=passphrase --batch --pinentry-mode loopback