3

I am trying to configure Gpg4win to not use the popup window to ask for a passphrase. I only use gpg2 from the command prompt, which means the popup window is both annoying and disruptive since it takes focus away from the command prompt and doesn't give it back afterwards.

This is on Windows 10.

I have tried editing the gpg-agent.conf file with the following content:

pinentry-program C:\...path-to\pinentry.exe

In the hopes that the pinentry.exe with no -w32 or similar ending is the one that will be used on the console but when trying to sign a test file it just sits there for a few seconds and then outputs:

$ gpg2 --sign test.md
gpg: problem with the agent: No pinentry
gpg: no default secret key: Operation cancelled
gpg: signing failed: Operation cancelled

I tried adding quotes around the path and forward slashes so I tried all of the following:

pinentry-program 'C:\...path-to\pinentry.exe'
pinentry-program C:/...path-to/pinentry.exe
pinentry-program file://C:/...path-to/pinentry.exe

In my gpg.conf file the setting use-agent is already commented out, as I found a tip on various websites about but I suspect this is an older setting for gpg (1) and not for gpg2.

I tried adding no-use-agent to the gpg.conf instead and got this:

gpg: C:/.../gpg.conf:202: obsolete option "--no-use-agent" - it has no effect

So is this possible at all?

Basically what I want is that this command:

gpg2 --sign test.md

Should prompt for my passphrase in the same command prompt window before continuing.

5
  • That may be the biggest reason I never liked gpg2, ignoring --no-use-agent, I think it even ignored --passphrase=... always popping up it's password entry window. It's like a terminal program that seems to actively hate the terminal. Have you tried running the pinentry.exe yourself in a terminal, verify that it works and the path is correct? On linux when I run pinentry (from pinentry-curses package) it says OK Your orders please and tells me ERR ... unknown command (I don't know the magic commands it wants, it's not read or get ;-)
    – Xen2050
    Commented Mar 17, 2017 at 14:04
  • Yes, the pinentry program asks for orders, on the console, yes. It's just that I can't seem to persuade gpg-agent to use it. Commented Mar 17, 2017 at 17:10
  • It seems like there's something funny about the config file not listening to or finding the pinentry program, but I don't know how to get windows & gpg4win to "get it together." Maybe trying --pinentry-mode loopback may do something different?
    – Xen2050
    Commented Mar 22, 2017 at 21:41
  • @Xen2050: I believe that --pinentry-mode loopback requires allow-loopback-pinentry in the gpg-agent.conf file.
    – harrymc
    Commented Sep 27, 2018 at 7:35
  • Try to add to gpg-agent.conf the pinentry-tty command.
    – harrymc
    Commented Sep 27, 2018 at 7:40

1 Answer 1

3

I used Gpg4win v3.1.15, it seems to use appdata directory as default home directory. If your home directory is different, the gpg.conf must be stored in there.

Create file if it doesn't exist already %appdata%\gnupg\gpg.conf with contents:

pinentry-mode loopback

If you enable that, you get a command line prompt.

Additionally this same setting allows you to pass the pin as command line option passphrase e.g. gpg --passphrase 12345 --decrypt, which of course is unsafe depending on your use case. If you are doing programmatic stuff it might be handy instead of typing in standard input.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .