How to force GPG to use console-mode pinentry to prompt for passwords?
To change the pinentry permanently, append the following to your ~/.gnupg/gpg-agent.conf
:
pinentry-program /usr/bin/pinentry-tty
(In older versions which lack pinentry-tty, use pinentry-curses for a 'full-terminal' dialog window.)
Tell the GPG agent to reload configuration:
gpg-connect-agent reloadagent /bye
On a debian box:
sudo apt install pinentry-tty
sudo update-alternatives --config pinentry
(and set it to pinentry-tty)
I just had this problem on Ubuntu 16.04.3 when trying to generate/install a private key using gpg2 (2.1.11) on a system account without a password, and on a user account over ssh. Nothing worked giving:
gpg: key FE17AE6D/FE17AE6D: error sending to agent: Permission denied
gpg: error building skey array: Permission denied
I then found this which worked for me, so in brief:
pico ~/.gnupg/gpg-agent.conf
# add: allow-loopback-pinentry
gpg-connect-agent reloadagent /bye
gpg2 --pinentry-mode loopback --import private.key