I'm trying to use a passphrase-protected GPG key with Obnam, which invokes gpg
(1.4.x on Ubuntu Server 14.04) in batch mode. gpg
can't ask for the password in batch mode. All gpg-agent
stuff that I find seems to involve a GUI dialog, but I'm using Ubuntu Server over ssh and the server doesn't have x.org installed.
What's a non-GUI equivalent of ssh-add
for GPG? That is, it'd like to invoke something that works in the terminal to cache the passphrase or the unlocked key in RAM and then invoke obnam
, which in turn invokes gpg
in batch mode, and have this work.
First install
pinentry-curses
and then installgnupg-agent
. Create a file calledgpg-agent.conf
inside yourGNUPG_HOME
directory (usually~/.gnupg
) and put something likein the file. (The numbers are cache validity durations in seconds.)
Then, to cache the unlocked key, run
followed by some
gpg
operation that requires the key to be unlocked.