“gpg: problem with the agent: No pinentry” — SOLVED

When trying to create a key with gpg –gen-key, I was getting the error:

gpg: problem with the agent: No pinentry

To solve this, first check if pinentry is installed. On Debian systems, use:

apt-get install pinentry

or on Redhat/Centos, use:

yum install pinentry

If you still get the error and you’re running gpg from the command line, the problem is that pinentry is set up to run in a GUI by default. You need to tell GPG to use the “curses” version of pinentry that can be run in a terminal. To do this, edit the GPG config file:

vi /etc/gnupg/gpg-agent.conf

Add or change the line with pinentry-program so that it looks like this:

pinentry-program /usr/bin/pinentry-curses

That’s it! Let me know in the comments if this works for you.

This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to “gpg: problem with the agent: No pinentry” — SOLVED

  1. chanbalamb says:

    Thanks dude woks! in openSUSE 13.1 just reload the terminal and its all.

  2. floman says:

    Worked, thank you (had to adapt it a bit for ubuntu)

  3. edgexs says:

    Worked with centos 7.6, thx! Should also issue the reload command gpg-connect-agent reloadagent /bye

  4. Pandu says:

    Didn’t work for me.
    # gpg –cipher-algo AES256 -c password
    gpg: problem with the agent: No pinentry
    gpg: error creating passphrase: Operation cancelled
    gpg: symmetric encryption of `password’ failed: Operation cancelled

    • david says:

      try
      gpgconf –kill gpg-agent
      echo ‘pinentry-program /usr/bin/pinentry-curses’ > ~/.gnupg/gpg-agent.conf
      gpg-agent –daemon
      echo test | gpg –clear-sign

  5. Chris says:

    This solved a very confounding problem I was having – thanks for posting!
    For reference, maybe this will help others:
    If running macOS and using MacPorts version of Pass,
    you can find the gpg-agent.conf at ~/.gnupg/gpg-agent.conf
    and the referenced pinentry-curses location should be in /opt/local/bin/
    so enter the line below into gpg-agent.conf:
    pinentry-program /opt/local/bin/pinentry-curses

Leave a comment