Non-interactive password-change with gnupg 2.0?

Pablo Santee pablo-gnupg at
Thu Jan 5 21:07:04 CET 2017


I'm trying to write code to change the passphrase of a key without
user-interaction that works with both, gpg 2.0 and gpg 2.1.

For gpg 2.1 I'm using
'--pinentry-mode loopback --command-fd 0 --status-fd 2'
and an expect-style script (not a pretty concept, IMHO, but it works).

For gpg 2.0 the only way I found was to write a custom pinentry-script,
pass it the passwords in PINENTRY_USER_DATA and give its path to the
gpg-agent with '--pinentry-program'. The custom pinentry-script stores
its state (how many times has the passphrase been asked for) in the
filesystem to access it across the three executions.

But I'd rather like to avoid to start a gpg-agent manually, and to
maintain another script (which has to write into the filesystem), if any

Is there another way to do it?

Thankful for pointers,

More information about the Gnupg-users mailing list