I use gpg-agent sometimes with no X display or over ssh, so my config file contains:
pinentry-program /usr/bin/pinentry-curses
This way, the gpg passphrase is requested in curses.
That said, in some graphical scripts, I wish to use the GTK pinentry instead. How to call gpg and temporarily use a different pinentry?
Best Answer
You can use the
PINENTRY_USER_DATA
environment variable to givegpg
information to pass to the pinentry command. You then need to setpinentry-program
to a custom wrapper such as this that will run the curses or the GTK pinentry depending on that variable.Note that this only seems to work with GPG 2.x, contrary to what the documentation of GPG 1.x says.
So with that script, you use
gpg2
to usepinentry-curses
andPINENTRY_USER_DATA="gtk" gpg2
to usepinentry-gtk-2
.