LLLanyard

Guides

Stop AI agents reading .env files and SSH keys

Telling an AI agent not to read your .env file works until it doesn't: a long session, a confusing error, or a web page that tells it to. A hook turns the request into a refusal. LLLanyard can add one to Claude Code, and an audit command shows what an agent could still reach.

Turn on the Claude Code hook

lllanyard setup claude-code --hooks

This adds a check to Claude Code's settings (your other settings and hooks are kept). Before every file read, edit, search or shell command, Claude Code asks LLLanyard whether the call touches a secret. If it names a .env file, an SSH private key or a credential file such as ~/.aws/credentials, the call is refused and Claude is told to use lllanyard exec or lllanyard ssh instead.

Its limits

The hook looks at the paths a call names. A command that builds a path while it runs gets past it, so it stops a careless or tricked agent, not a determined attacker. For a hard boundary, run the tool under lllanyard tool add --sandbox.

See what's left with lllanyard audit

$ lllanyard audit
HIGH   2 plaintext keys in files an AI agent can read
         openai     sk-proj…FfC1     ~/.zshrc:1
       fix: lllanyard scan --import --apply --redact
HIGH   SSH private key on disk with no passphrase: ~/.ssh/id_ed25519
       fix: lllanyard ssh add <name> --host user@host --key-file ~/.ssh/id_ed25519
MEDIUM OpenAI Codex is installed but not set up to use LLLanyard
       fix: lllanyard setup codex

It looks for plaintext keys in .env files, shell profiles and MCP configs, SSH private keys in ~/.ssh, keys overdue for rotation, SSH logins that have expired, and AI tools that are installed but not connected. It prints where things are with masked values, never a secret. The exit code is 1 if anything needs fixing, so you can run it in a script; --json gives the same as data.

Recommended order

  1. Run lllanyard audit.
  2. Move the plaintext keys into the keychain with lllanyard scan --import --apply --redact.
  3. Add your SSH keys with lllanyard ssh add, check they work, and delete the files.
  4. Connect your tools with lllanyard setup, and turn on the hook for Claude Code.
  5. Run the audit again.

More guides