Overview:
On macOS Ventura, after a key has been unlocked in gpg-agent once, attempting to access that same key from multiple clients in parallel will result in prompts to unlock the key again for some subset of the clients.
Environment:
macOS Ventura 13.2
gpg-agent (GnuPG) 2.4.0
libgcrypt 1.10.1
Reproduction Instructions
The following commands will demonstrate the problem on macOS. Even though the gpg key has already been unlocked previously, when running in parallel, we're prompted for the password.
sh # encrypt a file to yourself to work with echo "blah" | gpg -e -r $USER > data.gpg # decrypt the file once to ensure gpg-agent has the key gpg -d data.gpg # Now decrypt it repeatedly in serial; you should not see passphrase prompt for i in {0..5}; do gpg -d data.gpg; done # Now decrypt it in parallel; you will be prompted for passphrase for i in {0..5}; do (gpg -d data.gpg) & done
Background:
Why does this absurd case matter? Well, I'm using ansible with passwordstore to store secrets. Passwordstore uses gpg under the hood for encryption. Ansible runs against multiple hosts in parallel, so gpg is being run to decrypt various files with the same key in parallel repeatedly.
This problem does not reproduce on my old linux system, just on this macOS system.