How to make the default-cache-ttl option of gpg-agent work

cachegpggpg-agentpassword-storepinentry

I use pass as a password manager. I would
like my passphrase to be cached during a certain amount of time to avoid
retyping my passphrase every time that I want to clip one of my passwords.
Pass is using gpg-agent to decrypt
passwords.

According to the man page and a previously answered question, the solution is to set up the following options in ~/.gnupg/gpg-agent.conf:

default-cache-ttl 3600
max-cache-ttl 86400

Unfortunately, it does not work on my machine, I am asked for my passphrase each time I ask for a password.

I have verified that my gpg-agent.conf is read by adding and removing the
no-grab option. This works fine.

I am on a Debian machine with i3wm desktop. So I do not use gnome-keyring manager.

Best Answer

I solved the problem by upgrading gnupg from 1.4 to 2.1 which seemed to simplify a lot the configuration.

However, it generated an error of migration of the secret key between gpg and gpg2.

gpg2 generated the following error message when I was requiring password from pass:

gpg: decryption failed: No secret key

The solution came from this previous issue:

gpg --export [ID] > public.key
gpg --export-secret-keys [ID] > private.key
gpg2 --import public.key
gpg2 --import private.key
rm public.key private.key

with [ID] being the id of my key. It imports correctly the keys from gpg to gpg2.

Finally I rebooted and now my passphrase is cached, which makes me a really happy user of pass.

Related Question