3

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.

0

First install pinentry-curses and then install gnupg-agent. Create a file called gpg-agent.conf inside your GNUPG_HOME directory (usually ~/.gnupg) and put something like

pinentry-program /usr/bin/pinentry-curses
default-cache-ttl 31536000
default-cache-ttl-ssh 31536000
max-cache-ttl 31536000
max-cache-ttl-ssh 31536000

in the file. (The numbers are cache validity durations in seconds.)

Then, to cache the unlocked key, run

GPG_TTY=$(tty)
eval "$(gpg-agent --daemon)"

followed by some gpg operation that requires the key to be unlocked.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.