GPG Agent
dotsecenv uses your existing gpg-agent configuration. This guide covers cache settings and pinentry for commands you run in your terminal and calls made by an agent plugin. For other configuration options, see the GnuPG manual.
Health check
Section titled “Health check”Before debugging anything specific, confirm the agent is reachable and the rest of the dotsecenv environment is healthy:
dotsecenv vault doctordoctor verifies that gpg-agent is available, the vault format is current, and the vault is not fragmented. If gpg-agent is not running, doctor reports it and exits non-zero.
To talk to the agent directly:
gpg-connect-agent /bye# OK ← agent is runningTo list the agent’s current settings:
gpgconf --list-options gpg-agentRecommended gpg-agent.conf
Section titled “Recommended gpg-agent.conf”The same configuration used elsewhere in the documentation. Tuned for usability while still requiring re-entry on a regular cadence:
# Use a GUI pinentry appropriate for your platform:# macOS: pinentry-program /opt/homebrew/opt/pinentry-mac/bin/pinentry-mac# Linux: pinentry-program /usr/bin/pinentry-gnome3
# Passphrase expires after 1 hour of inactivitydefault-cache-ttl 3600
# Hard cap: passphrase must be re-entered after 4 hours regardless of activitymax-cache-ttl 14400
# Prevent pinentry from storing passphrases in the OS keychainno-allow-external-cacheFor the security rationale behind each option — why no-allow-external-cache matters, when to set both TTLs to 0 for maximum security, and how the OS keychain interacts with these settings — see Threat Model: Recommended GPG Agent Configuration.
Apply and verify
Section titled “Apply and verify”After editing the config, run these commands in your terminal to confirm the agent picked up your changes and that the cache holds across calls.
-
Reload the agent so the new values take effect without interrupting in-flight operations:
Terminal window gpgconf --reload gpg-agentThe older
killall gpg-agentworks, but it cuts off any decryption already in progress. Use the reload instead. -
Confirm the agent now reports the TTLs you set:
Terminal window gpgconf --list-options gpg-agent | grep -E '^(default-cache-ttl|max-cache-ttl):'# default-cache-ttl:0:0:N:N:0:::3600:# max-cache-ttl:0:0:N:N:0:::14400:The number after the seventh colon is the current value. If you see
0or your previous setting instead of3600/14400, you reloaded a differentGNUPGHOMEthan you edited. Cross-checkgpgconf --list-dirs homediragainstecho $GNUPGHOMEand try again. -
Unlock the signing key and the key needed for the requested decryption. Then check that the same decryption succeeds with pinentry disabled:
Terminal window gpg --sign --local-user YOUR_FINGERPRINT </dev/null >/dev/null # pinentry prompts heredotsecenv secret get ANY_SECRET >/dev/null # may unlock a different keydotsecenv --no-pinentry secret get ANY_SECRET >/dev/null # fails if pinentry is still requiredIf the final call reports
GPG_ERR_NO_PIN_ENTRY, the required credentials are not available without pinentry. Check the cache policy and confirm that each call uses the same GPG home. The error does not establish why pinentry was needed.
Cache entries expire according to default-cache-ttl and max-cache-ttl.
Different keys can require separate unlocks. For automated use, unlock the
required keys outside the agent session before retrying the operation.
Pinentry compatibility
Section titled “Pinentry compatibility”Calls to dotsecenv let GPG use its configured pinentry when interaction is needed. The prompt interface depends on the configured program:
| Pinentry program | Prompt interface | Required session access |
|---|---|---|
pinentry-mac |
macOS dialog | macOS desktop session |
pinentry-gnome3 |
GNOME dialog | Graphical session and its prompt service |
pinentry-qt |
Qt dialog | Graphical display session |
pinentry-tty |
Terminal input | A terminal that accepts input for pinentry |
pinentry-curses |
Terminal interface | A terminal that accepts input for pinentry |
An inherited GPG_TTY identifies a terminal; pinentry also needs access to
its input. Agent terminal interfaces can compete with pinentry for that input.
GUI pinentry uses a separate window when the graphical session is available.
Some graphical variants can fall back to curses, so the program name alone
does not establish that a prompt will work.
Agent calls
Section titled “Agent calls”The Claude Code and Codex skills add --no-pinentry to every dotsecenv call.
Adding this argument lets GPG use credentials already available to gpg-agent
and suppresses all pinentry programs, including pinentry-mac. An operation
that needs pinentry returns GPG_ERR_NO_PIN_ENTRY with exit code 4.
Credentials held only by a pinentry program’s external cache are unavailable
through this path.
The skill stops on this error and waits for user action. To prepare credentials
for plugin retrieval, complete the signing and decryption checks
in your own terminal with the same GPG home (GNUPGHOME, if set), then tell
the agent to retry. Each required key may need its own unlock.
You can also prepare secrets as environment variables before starting the
agent. The Claude Code guide covers .secenv loading,
manual exports, and plugin retrieval using cached credentials.
Cache warming for non-interactive use
Section titled “Cache warming for non-interactive use”Run the signing and decryption checks from your terminal before automated use. Your GPG cache policy determines how long the required credentials remain available. The agent calls section describes what happens when an operation needs pinentry during a session.
GPG_TTY for terminal sessions
Section titled “GPG_TTY for terminal sessions”GPG needs to know which terminal to attach pinentry to. Most shells set this automatically; if not, add it to your shell init:
# ~/.bashrc or ~/.zshrcexport GPG_TTY=$(tty)set -gx GPG_TTY (tty)Without GPG_TTY, you may see Inappropriate ioctl for device when the agent tries to prompt.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Likely cause | First thing to try |
|---|---|---|
gpg: agent_genkey failed: No agent running |
Agent not started, or wrong GNUPGHOME |
gpg-connect-agent /bye; if it errors, run gpgconf --launch gpg-agent |
Inappropriate ioctl for device from secret get or secret store |
Terminal pinentry without GPG_TTY |
export GPG_TTY=$(tty) and try again |
Passphrase prompt every time you run secret get |
default-cache-ttl 0 or no-allow-mark-trusted overriding cache |
Set default-cache-ttl 3600 and reload: gpgconf --reload gpg-agent |
secret get hangs in CI/AI-agent contexts then times out |
Terminal pinentry trying to prompt with no controlling terminal | Switch to a GUI pinentry, then warm the cache before running the job |
gpg: signing failed: Card error or smartcard not detected |
YubiKey/smartcard not inserted, or scdaemon cannot reach the reader |
gpg --card-status; reinsert the card if missing |
For broader threat-model context — what dotsecenv does and does not protect against, why caching is a security trade-off, and how the OS keychain factors in — see Threat Model.
Related
Section titled “Related”- Threat Model — security rationale for the recommended config
- Claude Code guide — the AI-agent-specific cache-warming pattern
- GnuPG Agent Configuration manual — daemon lifecycle, socket paths, and options beyond this page
