I started gpg-agent as follows:
eval `gpg-agent --daemon --preset`
and in this terminal window, used the gpg-preset-passphrase command as recommended:
echo secretpassword | /usr/libexec/gpg-preset-passphrase --preset KEYGRIPID
I then used this answer to verify the password was indeed correctly cached:
echo 'GET_PASSPHRASE --no-ask KEYGRIPID Err Pmt Des'|gpg-connect-agent |
perl -pe 's/([0-9a-fA-F]{2})/chr(hex $1)/eg'
When I now run gpg to sign or encrypt something, I get prompted for a password. This should not happen.
gpg -u KEYGRIPID --clearsign --batch somefile.txt
<curses-based prompt>
Once I enter the password correctly, and re-run the gpg-sign command, I do not get prompted. This indicates that the password is cached, albeit differently.
gpg version 2.0.14