You might be wondering how can you actually determine the duration of the passphrase cache that is stored in gpg-agent. Does the GPG tool has the ability to read the cache duration? The answer (as for the current gpg (GnuPG) 2.2.27) is NO. However, there is a trick how you can get cache duration left in gpg-agent:

If you don’t want to waste time for explanation, I wrote an implementation for this for GPG wrapper using bash script that can be located here: https://github.com/sofibox/maxigpg_public/blob/main/maxigpg

And you might be interested in the function of gpg_show_valid_info()

Leave a Reply