I only know a way* of getting the information of the presence of a cached GPG passphrase, that is, to run

$ gpg-connect-agent 'keyinfo --list' /bye
S KEYINFO 01B3BE66C2EAC153C4ED25F01FEE13D356EF289F D - - 1 P - - -
S KEYINFO 08933C3EB4D922575AF88298E09B770F66C56BFA D - - - P - - -

in which the 1 next to the P indicates the presence of the key with the corresponding keygrip in the cache.

The problem with this method is that the command above resets the entry's timer of the agent, which is a "problem" when one wants to check the availability of the cached passphrase every few seconds without resetting the timer along with each check. To be clear, a consequence of this behavior is that if the frequency of the check is higher than default-cache-ttl** seconds, then the cache will never be discard before max-cache-ttl seconds.

Is there a way to check if the key is in the cache without resetting the timer?

* I also tried the method in https://unix.stackexchange.com/a/79421/70214, but I could not make it work.

** For extra info, see section referring to --default-cache-ttl in the manpage of gpg-agent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.