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
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:
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.