How to make gpg prompt for passphrase on CLI

Mayank Pundir picture Mayank Pundir · Jul 21, 2013 · Viewed 28.7k times · Source

The encryption tool of gnuPG package gpg prompts for passphrase using a GUI dialog box when invoked by a regular user, however when invoked by root it prompts on CLI. How to make it use the CLI even when invoked by a regular user. version:GnuPG 1.4.12

Answer

Skyr picture Skyr · Jul 22, 2013

This kind of password prompt is not done by gpg itself, but by the gpg-agent.

You can configure your gpg-agent which pinentry program should be used. There are options both when starting the agent and in the gpg-agent config file -- please have a glance at the man page.

So I see two options:

  • Configure your gpg-agent to use the desired method
  • Disable the gpg-agent; you can do that for a single gpg invocation by unsetting the environment variable GPG_AGENT_INFO like GPG_AGENT_INFO="" gpg .... gpg used to have a --no-use-agent option, but this has been marked deprecated and has no functionality in recent gpg version.