There is an option named default-cache-ttl that controls how long the agent will remember the password to the private key. However, when I put it in the config file it doesn't work - instead, gpg complains:

gpg: /home/jan/.gnupg/gpg.conf:8: invalid option

My version of GPG is

$ gpg2 --version
gpg (GnuPG) 2.1.11

2 Answers 2


Wrong config file. This option concerns gpg-agent only, and (somewhat surprisingly) it has a separate configuration file - .gnupg/gpg-agent.conf. Put the option there and it works (configuration for GPG 2.1, earlier versions use different option names):

$ cat .gnupg/gpg-agent.conf
# remember the password longer (1 hour since last usage, 5 hours max)
default-cache-ttl 3600
max-cache-ttl 18000

I am getting the same error after starting gpg-agent. using the following CLI option worked (set a cache TTL of 1 month, f.e.):

gpg-agent --default-cache-ttl 2629800

but I don't know where eventually the value was set.

  • I think a config option specified like that is not saved anywhere, it will last only for the duration of that instance of gpg-agent. Jan 27, 2022 at 13:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .