#!/bin/bash # Go to home directory for sure pushd $HOME >/dev/null # Kill gpg-agent pkill gpg-agent # Rewrite gpg-agent configuration cat > ~/.gnupg/gpg-agent.conf < "${_dummyfile}" # Cache password in gpg-agent by signing dummy file cat ~/passphrase.txt | env -i gpg \ --pinentry-mode loopback --passphrase-fd 0 \ --no-tty --batch --yes \ --detach-sig --output "${_dummyfile}.sig" "${_dummyfile}" # Verify given signature env -i gpg --verify \ "${_dummyfile}.sig" "${_dummyfile}" echo $? rm "${_dummyfile}" "${_dummyfile}.sig" popd >/dev/null