Skip to content
itskdherePublic

About

zero-cloud, asymmetric envelope encryption for environment secrets πŸ”

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

71 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EnvLock (el)

CI Β  Release Β  Version

Zero-cloud, tamper-evident asymmetric envelope encryption for environment secrets.
Keep your .env files local and uncommitted while securely checking encrypted snapshots (env.lock) directly into Git.

πŸš€ Key Features

  • Zero Cloud & Zero SaaS: Pure Curve25519 (X25519 ECDH) asymmetric key exchange and AES-256-GCM envelope encryption. No cloud accounts, tokens, or servers.
  • Sub-10ms Latency: Instantaneous push/pull operations with hardware-accelerated standard library cryptography.
  • Byte-for-Byte Fidelity: Preserves 100% of formatting, comments (#), section dividers, multiline values, and custom quoting.
  • Process-Table Hardened: Strictly disallows passing private keys as CLI argument strings to prevent leaking secrets to ps aux or shell histories.
  • Ergonomic Short Alias (el): Ships with both envlock and the short alias el out of the box.

⚑ Quick Install / Update

macOS & Linux

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

Windows (PowerShell)

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

Go Developers

go install github.com/itskdhere/envlock@latest

Tip

Prefer direct scripts or want to inspect before running?

To install a specific release or change the install location, set ENVLOCK_VERSION (e.g. v0.8.0) or ENVLOCK_INSTALL_DIR. With the shell installer, put them right before bash: curl -fsSL https://envlock.itskdhere.com | ENVLOCK_VERSION=v0.8.0 bash.

EnvLock checks GitHub for a new release at most every 6 hours and prints a one-line 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

1. Initialize your repository

envlock init
# or: el init

Adds safety rules to .gitignore (ignoring .env, .env.*, *.key, and *.pub while keeping .env.example, env.lock and env.*.lock tracked) and .gitattributes (binary merge protection).

2. Generate your identity keypair

envlock keygen
# or: el keygen

Interactively prompts you to choose between saving the keypair locally (in the current project) or globally (in your user config directory). You can bypass the prompt by specifying --local (-l) or --global (-g).

Creates envlock.key (readable only by you, on every OS) and envlock.pub (or default.key and default.pub when global). EnvLock warns if a local key isn't gitignored, or if another key or existing env.lock is already present. In terminals that support OSC 52, the public key is also copied to your clipboard.

Tip: Use envlock keygen --global (or -g) to store your keypair centrally in your user config directory (~/.config/envlock/keys/ or %APPDATA%\envlock\keys\) across all projects.

Key Precedence: EnvLock picks the first key found from --key-file, ENVLOCK_KEY, ENVLOCK_KEY_PATH, ./envlock.key, then global default.key. push and pull print which key source was used; use --key-file <path> (or ENVLOCK_KEY_PATH) to switch keys or authorize a new local key using an existing global key.

3. Encrypt local .env into env.lock

envlock push
# or: el push

Encrypts your plaintext .env into a tamper-evident env.lock file. You can safely commit env.lock to Git. Later pushes re-encrypt for the same recipients and need a key that can decrypt the current env.lock.

Editing env.lock by hand, including its recipient list, makes decryption fail. Anyone with write access can still replace the whole file, so treat unexpected env.lock changes in pull requests with care.

4. Decrypt env.lock into local .env

envlock pull
# or: el pull

Restores the exact .env file byte-for-byte. If local unpushed changes exist, EnvLock lists which variables were added, modified, or removed locally and asks before overwriting (--force / -y to bypass).

5. Run commands with secrets injected in memory

envlock run -- npm start
# or: 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 ever 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, to keep a literal $.

πŸ‘₯ Team Access

Each teammate runs envlock 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

In a terminal, ls marks your own key with (you) and shows the active (and any shadowed) key source. When piped, it prints one bare key per line for scripts.

add and rm decrypt env.lock with your key and re-encrypt it under a fresh key for the new recipient list, then you commit the result. A removed key can't decrypt the new env.lock, but it can still decrypt older versions in Git history and has already seen the secrets, so rotate them after revoking access.

env.lock isn't signed. Anyone with write access to the repo, including a removed teammate, can commit a new env.lock that also encrypts for their own key. push, add, and rm remember which keys you last encrypted each env.lock for and ask before encrypting for any others (-y / --force skips the question), so check unexpected keys with your team. The first run on a machine trusts whatever env.lock lists, so also review the recipients list whenever env.lock changes in a pull request.

Each push, add, and rm rewrites the whole file, so changes to env.lock on two branches can't be merged: Git makes you keep one side, and keeping the side without an rm restores the removed key. pull and run warn about the restored key on any machine that has encrypted this env.lock before, and push, add, and rm ask before encrypting for it again, but pull the latest env.lock before running these commands. rm also asks before removing your own key.

To make sure no one can merge an env.lock change without approval, give the lock files owners on GitHub (or the equivalent on your Git host) with 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. GitHub then blocks merging any change to env.lock, including a forged one or a merge that restores a removed key, until one of those owners approves it.

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

Store your 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 itself is never passed on to the command. If no key can be resolved, EnvLock fails immediately 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.

πŸ“ Multi-Environment Support

Work seamlessly with multiple environments using the -e / --env flag:

# Encrypt .env.staging -> env.staging.lock
el push -e staging

# Decrypt env.staging.lock -> .env.staging
el pull -e staging

# Production
el push -e prod
el pull -e prod

πŸ“– 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 Encrypts raw .env bytes into env.lock for all authorized recipients
envlock pull el pull, dec Decrypts env.lock with uncommitted changes warning/prompt (-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
envlock version el version Prints semantic version, commit hash, and target architecture

Shell completion (including -e environment names) is available via envlock completion bash|zsh|fish|powershell. Set NO_COLOR=1 for plain, uncolored output.

πŸ”’ Security & Verification

All official release binaries and archives are signed with cryptographic build provenance using Sigstore and GitHub Artifact Attestations.

You can verify the authenticity and integrity of any downloaded binary or release asset using the GitHub CLI:

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

Examples:

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

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

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

About

zero-cloud, asymmetric envelope encryption for environment secrets πŸ”

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages