Skip to content

danilovera36/env-vault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

env-vault

Encrypt your .env files 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.

CI Python 3.9+ License: MIT


Overview

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.


✨ Features

  • πŸ”’ AES-256 encryption via Fernet (PBKDF2-derived keys, 600k iterations)
  • ☁️ AWS KMS support for team environments (envelope encryption)
  • πŸ‘ peek command β€” inspect key names without writing a file
  • πŸ›‘ init command β€” auto-configures .gitignore to protect .env
  • πŸ“‹ --stdout flag for piping into other tools
  • πŸ€– Works in CI/CD via VAULT_PASSWORD environment variable

πŸš€ Quick Start

# 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 unlock

πŸ“¦ Installation

pip install env-vault

# With AWS KMS support
pip install "env-vault[kms]"

πŸ”§ Commands

env-vault lock

Encrypt a .env file into a .vault file.

env-vault lock
env-vault lock --env-file .env.production --vault-file prod.vault

env-vault unlock

Decrypt 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 --stdout

env-vault peek

Inspect 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=****

env-vault init

Set up .gitignore to protect .env files.

env-vault init

☁️ AWS KMS

# 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-id

πŸ”„ Key Rotation

Rotating keys or passwords is straightforward with env-vault:

  1. Unlock your current vault using the old password/key: env-vault unlock --vault-file old.vault
  2. Lock the generated .env file using the new password/key: env-vault lock --vault-file new.vault --password new-pass
  3. 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.


πŸ‘₯ Team Workflow

env-vault is built for small, agile teams. A typical workflow looks like:

  1. Password Management: Use a shared vault (1Password or Bitwarden) to store the master VAULT_PASSWORD.
  2. Development: Developers clone the repo and run env-vault unlock to get started.
  3. Updates: When secrets change, one developer updates the .env, runs env-vault lock, and commits the updated .vault file.
  4. CI/CD: Inject the VAULT_PASSWORD as a secret variable in your CI platform (GitHub Actions, GitLab CI, etc.).

πŸ†š Comparison

Feature env-vault git-crypt sops
Simple CLI βœ… ❌ ❌
KMS native βœ… ❌ βœ…
No infra βœ… βœ… ❌


πŸ€– CI/CD

# GitHub Actions
- name: Unlock secrets
  env:
    VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }}
  run: |
    pip install env-vault
    env-vault unlock

πŸ”’ Security Notes

  • 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

🀝 Contributing

Pull requests are welcome. See CONTRIBUTING.md for details.


πŸ“ License

MIT Β© Danilo Vera

About

Lightweight secrets manager for .env files. AES-256 + KMS support. One command to lock/unlock. No infrastructure required. πŸ›‘οΈ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages