1

What is working

My gpg-agent pinentry works fine under X. I can run

echo "test" | gpg2 -ase --default-recipient-self | gpg2

to cache my passwords and later run killall gpg-agent -1 to flush them.

By default, it opens pinentry-gtk (from the looks of it) and prompts me for my password.

What is not working

However, if I try to run the same command without an X server, the it appears that gpg2 is hanging (no prompt or anything). If I kill it, then I can see that there is also a pinentry process which continues to exist but not anywhere useful.

What I expect to happen

I expect that running gpg2 without an X server would give me a pinentry-curses prompt, the same way that pass does. Additionally, I seem to remember that with older version of gpg, it just prompted me for my password from stdin, and I'm not quite sure why that doesn't happen either.

What I have tried

I have tried the following "fixes" but none have caused the aforementioned command to execute properly. In fact, forcing pinentry-curses causes the aforementioned command to fail even with the X environment (pass still works).

  • Setting pinentry-program /usr/bin/pinentry-curses in `gpg-agent.conf``

  • Starting gpg-agent like this: gpg-agent --daemon --keep-tty --use-standard-socket --pinentry-program=/usr/bin/pinentry-curses

  • using an environment variable: export PINENTRY_USER_DATA="USE_CURSES=1”

Background info

I have a nearly empty .gpg-agent config file; all it has is cache timeouts.

I am calling gpg-agent directly upon login like eval $(gpg-agent --daemon). I am not booting into X so I use getty to log in.

3

Oops... the answer was in the first screen's worth of man gpg-agent. I needed to add the following lines to my ~/.bashrc:

GPG_TTY=$(tty)
export GPG_TTY

The incorrect value of GPG_TTY explains why pinentry-curses was running, but not where I needed it to.

note: Since the output of tty changes between the console login and after I start my X server, this needs to be run on every ~/.bashrc (whereas most of my export'd environment variables are configured to only run on login).

0

If you are switching between X and tty often you may want to run

gpg-connect-agent updatestartuptty /bye > /dev/null

To set it to the current environment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.