Skip to main content

keystash 🔑

CI PyPI License

Local-first encrypted vault for API keys, tokens and passwords — one file, fuzzy search, env injection, expiry tracking, Touch ID unlock, and a leak hunter that cleans up the mess you already have.

Your LLM API keys, cloud tokens and passwords are scattered across .env files, shell histories and notes apps. keystash puts them in one encrypted file that you own: no server, no account, no subscription. Sync that file with iCloud / Dropbox / SeaDrive / Syncthing — it's ciphertext, so syncing it is safe.

pip install keystash
keystash init     # once; then `keystash unlock` for Touch ID–gated daily use

Why keystash

keystash pass / gopass Bitwarden / 1Password Infisical / Vault
Setup pip install + one password GPG key ceremony Account + app Self-host a server
Storage one encrypted file you own many GPG files vendor cloud server
Offline ✅ always ✅ partial ❌
Touch ID unlock ✅ built-in ❌ app-only ❌
Finds scattered plaintext keys on your machine ✅ doctor ❌ ❌ ❌
Dev workflow (env injection, run) ✅ built-in ❌ ❌ ✅ (heavy)
Token expiry tracking ✅ built-in ❌ ❌ enterprise

Touch ID unlock

Typing the master password for every command is exactly the kind of friction that pushes people back to plaintext notes. Unlock once and macOS gates it instead:

keystash unlock   # verify master password, store it behind Touch ID
keystash get openai -c   # → Touch ID prompt → copied
keystash lock     # remove the stored credential again

Every read shows the system authentication prompt (Touch ID → Apple Watch → device passcode fallback). --no-keychain or KEYSTASH_PASSWORD bypass it for scripts and CI. On machines without biometry the keychain still removes the typed password.

keystash doctor — clean up the mess you already have

Browser password managers only guard the keys you remember to move. doctor actively hunts the ones littering your machine:

keystash doctor                    # scan cwd + ~/.zshrc, ~/.zsh_history, ~/.env …
keystash doctor ~/projects         # scan any path
keystash doctor --import-all       # store every new finding in the vault
keystash doctor --import-all --shred --yes   # …and redact the plaintext in place

Knows OpenAI / Anthropic / GitHub / AWS / Google / Slack / Stripe / Hugging Face / SendGrid token shapes, PEM private keys, JWTs, plus an entropy-checked API_KEY=... sweep. Secrets already in the vault are reported as stored; --shred replaces each value with a [redacted→keystash:<name>] placeholder so file structure and comments survive.

Quick start

# 1. Create your vault (encrypted with AES-128-CBC + HMAC, PBKDF2-HMAC-SHA256 600k iters)
keystash init

# 2. Store a secret
keystash add openai --secret sk-... --tags llm,prod --expires 2027-01-31 --env-var OPENAI_API_KEY

# 3. Retrieve it
keystash get openai              # masked preview
keystash get openai -c           # → clipboard, auto-clears after 30 s
keystash get openai -q           # raw secret for scripts: export K=$(keystash get openai -q)

# 4. Find things (fuzzy)
keystash ls                      # everything, expiry warnings included
keystash ls oprod                # fuzzy: matches openai-prod
keystash ls --tag llm --json

# 5. Inject secrets into any command — nothing touches your shell or disk
keystash run -n openai -n anthropic -- python train.py
keystash run --tag llm -- python train.py
eval "$(keystash env --tag llm)" # or export them explicitly

# 6. Migrate off plaintext .env files
keystash import .env             # then delete the .env file

Commands

Command Purpose
init Create the vault
add NAME Store a secret (-s value, -g LEN to generate, -t tags, --expires YYYY-MM-DD, --env-var)
get NAME Show (-r reveal), copy (-c), raw output (-q)
ls [QUERY] List / fuzzy search (--tag, --json)
edit NAME Update any field in place
rm NAME Delete an entry
gen [LEN] Generate a strong secret (--save NAME to store it)
env NAME… / --tag Print export lines for shell eval
run -n NAME… -- CMD Run a command with secrets injected as env vars (--tag selects by tag)
import FILE Bulk-import .env or JSON
export Export metadata (or secrets with --with-secrets) as JSON / dotenv
unlock / lock Store / remove the master password behind Touch ID (macOS)
doctor Scan for scattered plaintext secrets; --import-all, --shred
status Vault health + expired / expiring-soon report

Multi-machine sync

The vault is a single encrypted file. Point KEYSTASH_VAULT at any synced folder:

export KEYSTASH_VAULT="~/CloudStorage/SeaDrive/vault.json"   # or iCloud, Dropbox, …

Each write re-encrypts with a fresh random salt, so last-writer-wins applies — prefer one writer per vault at a time, like any sync file.

Security model

  • Cipher: Fernet (AES-128-CBC + HMAC-SHA256, encrypt-then-MAC) via cryptography.
  • Key derivation: PBKDF2-HMAC-SHA256, 600 000 iterations, per-save 128-bit random salt.
  • File mode: 0600; nothing is ever written to disk in plaintext.
  • Clipboard: copied secrets are auto-cleared after 30 s (best effort, detached process).
  • No network. No telemetry. The CLI is fully offline.
  • Secrets live in process memory only while a command runs; Python cannot guarantee zeroization after exit — the same is true of any CLI in a GC'd language.

Environment variables

Variable Purpose
KEYSTASH_VAULT Vault file path (also --vault)
KEYSTASH_PASSWORD Master password (for scripts/CI; prefer the interactive prompt)

Development

git clone https://github.com/thu-lawyer/keystash && cd keystash
uv pip install -e ".[dev]"
pytest

License

MIT

Metadata

Release files for keystash 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keystash 0.2.0
File Size Uploaded
keystash-0.2.0.tar.gz 26.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for keystash 0.2.0
File Interpreter ABI Platform
keystash-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.3 kB

Release files / keystash-0.2.0.tar.gz

Download URL keystash-0.2.0.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c10e49666df94320fbd5f7a4a6a6ce093c69ef8de784cfb5a57dd6733e7d5f63
BLAKE2b-256 checksum
How to use checksums
e375f0f093f1ec327428b70184616693b91c09d541e339ed7b0849ad0097cfea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / keystash-0.2.0-py3-none-any.whl

Download URL keystash-0.2.0-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f10e32777e504522b1873e47abfafe41762beabb8c16869a54c8063bbd166c57
BLAKE2b-256 checksum
How to use checksums
c3da54fb5c62aaee14635fe6c6c50869b5bfaacb65bbebb783b1ad020390b3de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page