Caching your GnuPG passphrase

If you need to sign several files one after the other, we recommend gpg-agent, a program that will temporarily keep you passphrase in memory.

Depending on your GNU/Linux distribution, you can find precompiled packages:

  • Debian GNU/Linux and derivates (Ubuntu, Knoppix...): gnupg-agent (install with Synaptic, apt-get or dkpg).
  • Gentoo GNU/Linux: gpg-agent (install with emerge)
  • RPM-based (RedHat, Fedora...): gnupg2 (install with yum, apt-get for RPM or rpm)

You also need a pinentry program:

 aptitude install pinentry-gtk2
 echo "pinentry-program /usr/bin/pinentry" >> ~/.gnupg/gpg-agent.conf

Here is how to use gpg-agent in a simple way:

 gpg-agent --daemon > ~/.gpg-agent-info # start the daemon
 . ~/.gpg-agent-info # load settings (can be done from another terminal)
 gpg --sign -b --use-agent file.tar.gz # asked passphrase
 gpg --sign -b --use-agent file2.tar.gz # did not ask passphrase
 # ...
 killall gpg-agent # stop the daemon

See also UsingGnuArch for using gpg-agent when signing commits.