The user configuration (in ~/.gnupg/gpg-agent.conf) can only define the default and maximum caching duration; it can't be disabled.
The default-cache-ttl option sets the timeout (in seconds) after the last GnuPG activity (so it resets if you use it), the max-cache-ttl option set the timespan (in seconds) it caches after entering your password. The default value is 600 seconds (10 minutes) for default-cache-ttl and 7200 seconds (2 hours) for max-cache-ttl.
Set it to a year or so – say, 34560000 seconds (400 days) – and you should be fine:
GnuPG 2.1 and above
In GnuPG 2.1 and above, the maximum-cache-ttl option was renamed to max-cache-ttl without further changes.
default-cache-ttl 34560000
max-cache-ttl 34560000
GnuPG 2 and below
default-cache-ttl 34560000
maximum-cache-ttl 34560000
Restart the agent
But for this change to take effect, you need to end the session by restarting gpg-agent.
gpgconf --kill gpg-agent
gpg-agent --daemon --use-standard-socket
If you want to limit to your session length, you'd need to kill the daemon at logout. This is very different between operating systems, so I'm referring to another question/answer containing hints for different systems.
You could also restart the gpg-agent during login, but this does not limit caching time to the session length, but logins of a user. Decide yourself if this is a problem in your case.
gpg-agent. – Jens Erat Jul 29 '13 at 08:12maximum-cache-ttloption doesn't exist. To see the correct options, see the official documentation: https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#Agent-Options – Pablo Olmos de Aguilera C. Dec 27 '14 at 19:12default-cache-ttlis 600 seconds (10 minutes), not two hours. – jlh Oct 03 '17 at 09:30gpg-agent, the correct value seems to be 10 minutes for all releases. I edited the answer, thank you for pointing this out. – Jens Erat Oct 05 '17 at 10:32max-cache-ttl 34560000– Benjamin Abt Dec 17 '18 at 17:34log-fileoption -- if nothing is logged to that file, you're indeed probably using the wrong file. – Jens Erat Dec 17 '18 at 21:54gpg-agent.conffile at$env:AppData\gnupgI did this and it all seems to be working the way I want...
– CubanX Apr 23 '19 at 14:00I wonder what is different about your set up?
– CubanX Apr 30 '19 at 14:15gpg-agenthas picked up my config changesgpgconf --list-options gpg-agent | grep cache-ttl. Restarting the agentgpgconf --kill gpg-agent– mmrobins Jan 07 '22 at 04:35gpg-agent[34574]: gpg-agent (GnuPG) 2.3.6 started```– Karl Morrison May 25 '22 at 13:52