Skip to content
itskdherePublic

About

Zero-cloud, tamper-evident encryption for your .env files πŸ”

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

101 Commits

Folders and files

Repository files navigation

EnvLock logo

EnvLock (el)

CI Β  Release Β  Downloads Β  Version Β  License

Zero-cloud, tamper-evident encryption for your .env files.
Keep .env local and out of Git, and commit an encrypted snapshot (env.lock) instead. Each teammate decrypts it with their own key.

πŸš€ Key Features

  • Zero Cloud & Zero SaaS: Curve25519 (X25519) key exchange and AES-256-GCM envelope encryption. No accounts, tokens, or servers.
  • Fast: Push and pull are near-instant, using Go's hardware-accelerated standard library cryptography.
  • Byte-for-Byte Fidelity: Comments, blank lines, section dividers, multiline values, and quoting come back exactly as written.
  • Tamper-Evident: Every env.lock is signed by whoever pushed it, so hand edits and forged files are caught.
  • No Keys on the Command Line: Private keys are never accepted as CLI arguments, so they can't leak into ps aux or shell history.
  • Short Alias: Use envlock or just el.

⚑ Install / Update

macOS & Linux

curl -fsSL https://envlock.itskdhere.com/install | bash

Windows (PowerShell)

irm https://envlock.itskdhere.com/install | iex

Go

go install github.com/itskdhere/envlock@latest

This installs only envlock. The el alias comes with the install scripts and release archives.

The scripts are also available directly: install.sh, install.ps1.

To install a specific release or change the install location, set ENVLOCK_VERSION (e.g. v0.11.0) or ENVLOCK_INSTALL_DIR. With the shell installer, put them right before bash:

curl -fsSL https://envlock.itskdhere.com/install | ENVLOCK_VERSION=v0.11.0 bash

Update notices: EnvLock checks GitHub for a new release at most every 6 hours and prints a notice when one is out. That single HTTPS request to github.com is the only network call EnvLock makes. It is skipped in CI and when stderr isn't a terminal. Set ENVLOCK_NO_UPDATE_CHECK=1 to turn it off.

πŸ› οΈ Quick Start

el init               # add safety rules to .gitignore and .gitattributes
el keygen             # create your keypair
el push               # encrypt .env -> env.lock (commit this file)
el pull               # decrypt env.lock -> .env
el run -- npm start   # run a command with secrets in memory, no .env on disk

el init

  • Adds rules to .gitignore: ignore .env, .env.*, *.key, and *.pub, but keep .env.example, env.lock, and env.*.lock tracked.
  • Adds rules to .gitattributes that tell Git never to merge lock files line by line.
  • Creates a sample .env if neither .env nor env.lock exists yet.

el keygen

Asks where to save your keypair: in the project (envlock.key / envlock.pub) or globally (default.key / default.pub, see Keys). Skip the question with --local (-l) or --global (-g).

The private key is readable only by you, on every OS. Share the public key (el_pub_...) with your team. In terminals that support OSC 52, it's also copied to your clipboard. EnvLock warns if a local key isn't gitignored, if another key takes precedence over it, or if an existing env.lock isn't encrypted for it yet.

el push

Encrypts .env into env.lock, which is safe to commit.

  • The first push encrypts for your key only. Later pushes keep the same recipients and need a key that can decrypt the current env.lock.
  • If env.lock changed since your last pull or push (say, a teammate pushed), EnvLock lists the variables your push would modify or delete and asks first.

el pull

Restores .env exactly as it was pushed. If your local .env differs, EnvLock lists which variables were added, modified, or removed locally and asks before overwriting.

Use -y / --force on push or pull to skip these questions.

el run

el run -- npm start
el run -e prod -- ./deploy.sh

Decrypts env.lock in memory and runs the command with its variables in the environment. No plaintext .env is written to disk.

  • Vault variables override host variables, unless you pass --no-override.
  • Stdin/stdout/stderr, Ctrl+C, and the exit code pass straight through.
  • If your local .env differs from env.lock, EnvLock warns you and uses the vault's values.
  • $VAR and ${VAR} in unquoted and double-quoted values expand from earlier keys, then the host environment. Unknown references are left as-is. Use single quotes, or \$ inside double quotes, for a literal $.

πŸ”‘ Keys

Global keys live in your user config directory:

  • Linux: ~/.config/envlock/keys/
  • macOS: ~/Library/Application Support/envlock/keys/
  • Windows: %APPDATA%\envlock\keys\

EnvLock uses the first key it finds, in this order:

  1. --key-file <path> (or --key-file - to read it from stdin)
  2. ENVLOCK_KEY (the key itself)
  3. ENVLOCK_KEY_PATH (path to a key file)
  4. envlock.key in the current directory, then each parent directory up to the Git root
  5. The global default.key

push and pull print which key they used. To use a different one, pass --key-file or set ENVLOCK_KEY_PATH.

πŸ‘₯ Team Access

Each teammate runs el keygen and shares their el_pub_... key. Anyone who can already decrypt env.lock can manage who else can:

el recipient ls                  # list the public keys env.lock is encrypted for
el recipient add el_pub_...      # authorize a teammate
el recipient rm el_pub_...       # revoke a teammate

add and rm re-encrypt env.lock under a fresh key. Commit the result. In a terminal, ls marks your own key with (you) and shows which key source is active. When piped, it prints one key per line for scripts.

A removed key can't decrypt the new env.lock, but it can still decrypt older versions in Git history, and that person has already seen the secrets. Rotate the secrets after revoking access.

How tampering is caught

  • Editing env.lock by hand, including its recipient list, makes decryption fail.
  • Every push, add, and rm signs env.lock with the pusher's key. Each machine remembers which keys it has verified for each env.lock.
  • If env.lock is signed by a key you haven't verified, run refuses to decrypt it and pull asks before trusting it (even with -y). A new teammate's first push needs this one-time confirmation, so check their key with your team first.
  • If a verified teammate signed it but added unexpected keys, pull and run warn you, and push, add, and rm ask before encrypting for those keys (-y skips the question).
  • Once a signed env.lock has been verified, unsigned ones are rejected.

What it can't stop: anyone with write access to the repo, including a removed teammate, can commit a new env.lock that adds their own key. Also, the first run on a fresh machine or CI runner trusts whatever recipients env.lock lists. So review every env.lock change in pull requests.

Merge conflicts

Each push, add, and rm rewrites the whole file, so env.lock changes on two branches can't be merged. Git makes you keep one side. If you keep the side without an rm, the removed key comes back. EnvLock warns about it on machines that saw the removal, but to avoid it, always get the latest env.lock from Git before running push, add, or rm. rm also asks before removing your own key.

Require approval for env.lock changes (GitHub)

Add a .github/CODEOWNERS file:

env.lock      @your-org/secrets-admins
env.*.lock    @your-org/secrets-admins

Then protect your default branch with Require a pull request before merging and Require review from Code Owners. No change to env.lock can then be merged, forged or not, until one of those owners approves it.

βš™οΈ CI/CD (Zero-Disk)

  1. Create a key for CI: el keygen --stdout prints a keypair without writing any files.
  2. Authorize it: el recipient add el_pub_..., then commit env.lock.
  3. Store the private key as a CI secret and expose it as ENVLOCK_KEY:
- run: envlock run -- npm test
  env:
    ENVLOCK_KEY: ${{ secrets.ENVLOCK_KEY }}

The key is never passed on to the command. If no key is found, EnvLock fails right away instead of waiting for input.

Exit codes are the command's own, or 125 if EnvLock fails (e.g. no key), 126 if the command can't be executed, and 127 if it isn't found, so CI can tell a secrets failure from a test failure.

πŸ“ Multiple Environments

Use -e / --env to pick an environment:

el push -e staging   # .env.staging -> env.staging.lock
el pull -e staging   # env.staging.lock -> .env.staging
el run -e prod -- ./deploy.sh

πŸ—‚οΈ Monorepos & Subdirectories

Commands work on the current directory. Run el init once at the repo root. Its rules cover every subdirectory, and a root envlock.key is found from any subdirectory.

To act on the whole tree, add -r / --recursive to push, pull, or recipient ls|add|rm:

el push -r                       # every .env below here -> its own env.lock
el pull -r                       # every env.lock below here -> its own .env
el pull -r -e prod               # every env.prod.lock -> .env.prod
el recipient add -r el_pub_...   # authorize a teammate in every vault

-r skips hidden directories (.git, .venv, ...), node_modules, vendor, and __pycache__. recipient add -r / rm -r skip vaults that already have (or don't have) the key. If one directory fails, the rest still run and the command exits non-zero.

To target one subdirectory without cd, pass -f / --file with a .env or env.lock path (it can't be combined with -e or -r):

el recipient add el_pub_... -f apps/api/env.lock   # only apps/api/env.lock
el pull -f apps/api/.env.prod                      # apps/api/env.prod.lock -> apps/api/.env.prod
el run -f apps/api/.env -- npm start               # only apps/api/env.lock

πŸ“– Command Reference

Command Alias Description
envlock init el init Prepares project safety defaults (.gitignore, .gitattributes, sample .env)
envlock keygen el keygen Generates a Curve25519 X25519 keypair (-l / --local, -g / --global, -o / --out, --stdout, -y / --force)
envlock push el push, enc, encrypt Encrypts .env into env.lock for all authorized recipients (-r, -y / --force)
envlock pull el pull, dec, decrypt Decrypts env.lock into .env, asking before overwriting local changes (-r, -y / --force)
envlock run el run Runs -- <command> with vault variables injected in memory (--no-override)
envlock recipient el recipient, rec Lists (ls), adds (add <pubkey>), or removes (rm <pubkey>) authorized public keys (-r, -y / --force)
envlock version el version, el -v Prints version, commit hash, and target OS/architecture

Flags on push, pull, run, and recipient: -e / --env <name>, -f / --file <path>, and --key-file <path> (or - for stdin).

Shell completion (including -e environment names): envlock completion bash|zsh|fish|powershell. Set NO_COLOR=1 for plain output.

πŸ”’ Verifying Releases

All release binaries and archives carry signed build provenance (Sigstore and GitHub Artifact Attestations). Verify one with the GitHub CLI:

gh attestation verify <path-to-binary-or-archive> --repo itskdhere/envlock

For example:

# Installed binary (macOS / Linux)
gh attestation verify $(which envlock) --repo itskdhere/envlock

# Installed binary (Windows PowerShell)
gh attestation verify (Get-Command envlock.exe).Source --repo itskdhere/envlock

# Downloaded release archive
gh attestation verify envlock_*_linux_amd64.tar.gz --repo itskdhere/envlock

πŸ—‘οΈ Uninstall

macOS & Linux

curl -fsSL https://envlock.itskdhere.com/uninstall | bash

Windows (PowerShell)

irm https://envlock.itskdhere.com/uninstall | iex

Or use Settings > Apps, or winget uninstall envlock.

Go

rm "$(go env GOPATH)/bin/envlock"   # envlock.exe on Windows

Uninstalling never deletes your keys. The scripts are also available directly: uninstall.sh, uninstall.ps1.

πŸ§‘β€πŸ’» Building from Source

Requires the Go version in go.mod.

make build   # bin/envlock and bin/el
make test    # go test -v ./...

🎨 Credits

Logo by: @saptarshiroy39


πŸ”

About

Zero-cloud, tamper-evident encryption for your .env files πŸ”

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages