Encrypt your
.envfiles with AES-256 and store them safely in Git. Unlock them on any machine with a password or AWS KMS key. Stop committing plaintext secrets.
env-vault is a lightweight CLI for encrypting .env files using AES-256 for safe storage in your Git repositories. It bridges the gap between committing plaintext secrets and using heavy secrets management infrastructure.
- π AES-256 encryption via Fernet (PBKDF2-derived keys, 600k iterations)
- βοΈ AWS KMS support for team environments (envelope encryption)
- π
peekcommand β inspect key names without writing a file - π‘
initcommand β auto-configures.gitignoreto protect.env - π
--stdoutflag for piping into other tools - π€ Works in CI/CD via
VAULT_PASSWORDenvironment variable
# Install
pip install env-vault
# 1. Initialize (adds .env to .gitignore automatically)
env-vault init
# 2. Lock (encrypt .env β .env.vault)
env-vault lock
# 3. Commit the vault β it's safe!
git add .env.vault && git commit -m "chore: add encrypted env vault"
# 4. On another machine β unlock
env-vault unlockpip install env-vault
# With AWS KMS support
pip install "env-vault[kms]"Encrypt a .env file into a .vault file.
env-vault lock
env-vault lock --env-file .env.production --vault-file prod.vaultDecrypt a .vault file back to .env.
env-vault unlock
env-vault unlock --vault-file prod.vault --env-file .env.production
# Print to stdout (useful for CI)
env-vault unlock --stdoutInspect key names in the vault without writing a file. Values are always masked.
env-vault peek
# Output:
# DATABASE_URL=****
# SECRET_KEY=****
# AWS_ACCESS_KEY_ID=****Set up .gitignore to protect .env files.
env-vault init# Lock with KMS
env-vault lock --kms-key-id arn:aws:kms:us-east-1:123456789:key/my-key-id
# Unlock with KMS
env-vault unlock --kms-key-id arn:aws:kms:us-east-1:123456789:key/my-key-idRotating keys or passwords is straightforward with env-vault:
- Unlock your current vault using the old password/key:
env-vault unlock --vault-file old.vault - Lock the generated
.envfile using the new password/key:env-vault lock --vault-file new.vault --password new-pass - Replace the old vault file in Git.
Note
If using AWS KMS, rotating the CMK (Customer Master Key) in AWS doesn't require a re-encryption of the vault if the key ARN remains the same and you utilize KMS key rotation.
env-vault is built for small, agile teams. A typical workflow looks like:
- Password Management: Use a shared vault (1Password or Bitwarden) to store the master
VAULT_PASSWORD. - Development: Developers clone the repo and run
env-vault unlockto get started. - Updates: When secrets change, one developer updates the
.env, runsenv-vault lock, and commits the updated.vaultfile. - CI/CD: Inject the
VAULT_PASSWORDas a secret variable in your CI platform (GitHub Actions, GitLab CI, etc.).
| Feature | env-vault | git-crypt | sops |
|---|---|---|---|
| Simple CLI | β | β | β |
| KMS native | β | β | β |
| No infra | β | β | β |
# GitHub Actions
- name: Unlock secrets
env:
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }}
run: |
pip install env-vault
env-vault unlock- Keys are derived using PBKDF2-HMAC-SHA256 with 600,000 iterations (NIST recommended)
- Each encryption uses a fresh random 16-byte salt β identical plaintexts produce different ciphertexts
- Encrypted blobs include a magic header (
ENVV) for format validation - Never stores or logs the master password
Pull requests are welcome. See CONTRIBUTING.md for details.
MIT Β© Danilo Vera