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.
- 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.lockis 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 auxor shell history. - Short Alias: Use
envlockor justel.
macOS & Linux
curl -fsSL https://envlock.itskdhere.com/install | bashWindows (PowerShell)
irm https://envlock.itskdhere.com/install | iexGo
go install github.com/itskdhere/envlock@latestThis 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 bashUpdate 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.
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- Adds rules to
.gitignore: ignore.env,.env.*,*.key, and*.pub, but keep.env.example,env.lock, andenv.*.locktracked. - Adds rules to
.gitattributesthat tell Git never to merge lock files line by line. - Creates a sample
.envif neither.envnorenv.lockexists yet.
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.
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.lockchanged since your last pull or push (say, a teammate pushed), EnvLock lists the variables your push would modify or delete and asks first.
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 -- npm start
el run -e prod -- ./deploy.shDecrypts 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
.envdiffers fromenv.lock, EnvLock warns you and uses the vault's values. $VARand${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$.
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:
--key-file <path>(or--key-file -to read it from stdin)ENVLOCK_KEY(the key itself)ENVLOCK_KEY_PATH(path to a key file)envlock.keyin the current directory, then each parent directory up to the Git root- 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.
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 teammateadd 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.
- Editing
env.lockby hand, including its recipient list, makes decryption fail. - Every
push,add, andrmsignsenv.lockwith the pusher's key. Each machine remembers which keys it has verified for eachenv.lock. - If
env.lockis signed by a key you haven't verified,runrefuses to decrypt it andpullasks 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,
pullandrunwarn you, andpush,add, andrmask before encrypting for those keys (-yskips the question). - Once a signed
env.lockhas 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.
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.
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.
- Create a key for CI:
el keygen --stdoutprints a keypair without writing any files. - Authorize it:
el recipient add el_pub_..., then commitenv.lock. - 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.
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.shCommands 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 | 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.
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/envlockFor 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/envlockmacOS & Linux
curl -fsSL https://envlock.itskdhere.com/uninstall | bashWindows (PowerShell)
irm https://envlock.itskdhere.com/uninstall | iexOr use Settings > Apps, or winget uninstall envlock.
Go
rm "$(go env GOPATH)/bin/envlock" # envlock.exe on WindowsUninstalling never deletes your keys. The scripts are also available directly: uninstall.sh, uninstall.ps1.
Requires the Go version in go.mod.
make build # bin/envlock and bin/el
make test # go test -v ./...Logo by: @saptarshiroy39