keystash 🔑
Local-first encrypted vault for API keys, tokens and passwords — one file, fuzzy search, env injection, expiry tracking.
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
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 | ❌ |
Dev workflow (env injection, run) |
✅ built-in | ❌ | ❌ | ✅ (heavy) |
| Token expiry tracking | ✅ built-in | ❌ | ❌ | enterprise |
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 |
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
Metadata
Release files for keystash 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| keystash-0.1.0.tar.gz | 16.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| keystash-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.8 kB
Release files / keystash-0.1.0.tar.gz
| Download URL | keystash-0.1.0.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d30b7d12bb79aba206b4149bc0c02c8b57bab5bb47c203d146215a23ceee81b9
|
|
BLAKE2b-256 checksum How to use checksums |
9551374c86779f80efeb73445f66208b1c109ad68570f6480cfd43f7bb967206
|
| 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 logRelease files / keystash-0.1.0-py3-none-any.whl
| Download URL | keystash-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3fc85aa8ee5293a12206b4b080aa03f4650a83cf975a591c52582696f29b5ae
|
|
BLAKE2b-256 checksum How to use checksums |
cef1d110f1769081db9fdfbf2714d8fa9aaf13945bbadebe9968b5d347c6e98f
|
| 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