{"slug": "show-hn-dotenc-git-native-encrypted-environments-powered-by-your-ssh-keys", "title": "Show HN: dotenc – Git-native encrypted environments powered by your SSH keys", "summary": "A project called dotenc launched as a Git-native secrets manager that encrypts environment variables with AES-256-GCM and wraps each environment's randomly generated 256-bit data key with developers' existing RSA or Ed25519 SSH public keys, so encrypted `.env.*.enc` files can be committed to a repository with no external service or extra key management. dotenc derives public keys from `~/.ssh/`, stores them in `.dotenc/`, rotates data keys on edits and access changes, and decrypts variables on the fly when running commands such as `dotenc dev npm start`; the project's SECURITY.md notes that AES-GCM detects ciphertext changes but does not prove who authored a complete replacement envelope, leaving authorship to Git permissions, review and history. The tool ships with an official dotenc skill and installs via a script or APT, RPM, APK, AUR, Homebrew, Scoop, npm, a standalone binary or an OCI image.", "body_md": "🔐 Git-native encrypted environments powered by your SSH keys\n\n- 🔒 Uses the battle-tested AES-256-GCM encryption algorithm\n- 🔑 Uses your existing SSH keys - no extra key management\n- 🚀 Secure command running with on-the-fly decryption\n- ✍️ Easy and secure environment variable editing\n- 🌍 Supports multiple and extensible environments\n- 👤 Personal encrypted environments per developer\n- 🔄 Automatic data key rotation on edits and access changes\n- 🔍 Readable local Git diffs and redacted pull-request reviews\n- 🛡️ Supports both RSA and Ed25519 SSH keys\n- 🤖 Ready for the AI era — check out the official [dotenc skill](https://www.skills.sh/dotenc/skills/dotenc)\n\n```\ndotenc init --name alice  # pick your SSH key and create personal.alice\ndotenc env edit personal.alice  # add your personal secrets\ndotenc dev npm start   # run with your encrypted env\n```\n\nEncrypted `.env.personal.alice.enc` committed.\nNo external services.\nUses your existing SSH keys.\nDone.\n\n```\ncurl -fsSL https://dotenc.org/install.sh | sh\n```\n\nThe installer selects a supported package manager for your system. To review\nthe script first or install manually with APT, RPM, APK, AUR, Homebrew, Scoop,\nnpm, a standalone binary, or an OCI image, see the\n[installation guide](https://github.com/dotenc/dotenc/blob/main/docs/INSTALLATION.md).\n\nManaging secrets and environment variables is critical for any modern application, but most solutions rely on third-party services and web dashboards. **dotenc** was created to solve these problems:\n\n- **No Vendor Lock-In:** Your secrets and keys live in your codebase and your repository. You're never tied to a third-party provider or forced to migrate if pricing or policies change.\n- **Improved Security:** Eliminate the risk of exposing secrets to external services. All encryption and decryption happen locally, and private keys never leave your machine.\n- **Zero Key Management:** You already have SSH keys. dotenc uses them directly - no custom key generation, no extra files cluttering your home directory, no new workflows to learn.\n- **Better Developer Experience:** No more juggling environment variables in a web UI or struggling to keep them in sync across branches. Everything is managed alongside your code, with simple CLI commands and full Git integration.\n- **Seamless Collaboration:** Onboard or revoke team members with a single command. Grant or remove access per environment, and let Git handle the rest.\n- **Reviewable in Git:** Grants and revocations change tracked files, so normal\nrepository review and history show access changes under your Git hosting and\nbranch-protection policy.\n- **PR-Safe Environment Changes:** Environment variable updates live in the same pull request as your feature code. No more \"merge → broken build → patch env → rebuild\" workflow.\n\n- Each environment has its own randomly generated 256-bit data key.\n- Data keys are encrypted per-user using their SSH public key.\n- dotenc uses AES-256-GCM for authenticated encryption.\n- Your repository alone is not enough to decrypt secrets.\n- Access can be revoked at any time.\n\nAES-GCM detects changes to a ciphertext under its data key; it does not prove who authored a complete replacement envelope. Repository writers are trusted, with Git permissions, review, and history providing the authorship layer.\n\nFor a detailed breakdown of the cryptographic design, key material handling, threat model, and vulnerability reporting, see [SECURITY.md](https://github.com/dotenc/dotenc/blob/main/SECURITY.md).\n\n1. dotenc detects your existing SSH keys in `~/.ssh/` (Ed25519 or RSA);\n2. Your public key is derived and stored in the project (`.dotenc/john.pub` );\n3. A unique data key is generated for each environment;\n4. The data key is encrypted with each authorized public key;\n5. Environment variables are encrypted using the data key with AES-256-GCM;\n6. Encrypted files (`.env.*.enc` ) are committed to your repository;\n7. When running commands, variables are decrypted on-the-fly using your SSH private key.\n\nBy default, filesystem SSH private keys stay in `~/.ssh/` and dotenc reads them\nin place. A persistent passwordless or 1Password-backed local copy is created\nonly through the explicitly confirmed opt-in flows documented below; provider\nkeys otherwise enter dotenc process memory only for the current operation.\n\nAfter setup, your project will look like:\n\n```\n.\n├── .dotenc/\n│   ├── alice.pub\n│   ├── bob.pub\n│   └── ...\n├── .env.personal.alice.enc\n├── .env.production.enc\n└── .env.development.enc\n```\n\nEncrypted files are committed to Git. Public keys are stored inside `.dotenc/`.\nEach developer can have a personal encrypted environment in the reserved\n`personal.<profile>` namespace (for example,\n`.env.personal.alice.enc`). Public-key filenames are display aliases only;\nprofile access is matched by key fingerprint.\n\nSeamlessly. dotenc connects encrypted environment files to Git's native diff pipeline. When an authorized developer runs `git diff`, dotenc decrypts both revisions locally with their SSH key and shows the change that matters—a variable added, removed, or updated—instead of a wall of regenerated ciphertext.\n\nOnly encrypted `.env.*.enc` files are stored and committed. The readable view exists only on the developer's machine, so local reviews stay clear without a manual decrypt-and-re-encrypt workflow—even though every edit rotates the data key and rewrites the ciphertext.\n\n`dotenc init` configures this automatically. Run it once in every clone. When it detects an existing dotenc project, it configures the clone-local Git driver without changing keys, environments, or access rules.\n\nThe driver is limited to `.env.*.enc`, and clone-local textconv caching is\ndisabled so Git does not persist decrypted output. `dotenc init` currently\nwrites the bare command `dotenc textconv`, so Git resolves `dotenc` from your\nmachine's `PATH`. Pinning a stable installed executable path is deferred; until\nthen, local executable resolution remains part of the trusted\ndeveloper-machine boundary.\n\nOptionally, you can also enable [redacted diffs in pull requests](#redacted-pull-request-diffs).\n\n```\ndotenc init\n```\n\nIn a new project, this interactively guides you through the setup process:\n\n1. Scanning your `~/.ssh/` directory for SSH keys (Ed25519, RSA, etc.);\n2. Prompting for your username (defaults to your system username);\n3. Letting you choose which SSH key to use;\n4. Deriving the public key and storing it in `.dotenc/` (e.g.,`.dotenc/alice.pub` );\n5. Creating encrypted `development` and personal environments (for example,`.env.development.enc` and`.env.personal.alice.enc` ).\n\nIn an existing clone, `dotenc init` only enables the local Git diff integration. It does not prompt for an identity or recreate keys and environments, so it is safe to run after every clone.\n\nNo keys to generate. If you already have an SSH key (and you probably do), you're ready to go.\n\nIf you don't have an SSH key yet, just run `ssh-keygen` first - you'll want one anyway.\n\n```\ndotenc env create [environment]\n```\n\nThis command creates a new encrypted environment file under the specified name (e.g., `.env.development.enc`). Your `personal.<profile>` environment is created automatically during `init`.\nEnvironment names may contain letters, numbers, dots (`.`), hyphens (`-`), and underscores (`_`).\n\nNew and rewritten environments use format version 2, which binds the logical environment name to the ciphertext. Existing version 1 envelopes remain readable, but renaming a version 2 file requires decrypting and re-encrypting it under the new name.\n\nIn a monorepo, `cd` to the target directory first, then run `dotenc env create`.\n\n```\ndotenc env rename <source> <destination> [--all-layers] [--yes]\n```\n\nThis decrypts and re-encrypts the content under the destination name rather\nthan moving the encrypted file. The default targets the current directory;\n`--all-layers` targets the effective ancestor chain. See the personal-profile\nmigration guidance below for its safety and recovery semantics.\n\n```\ndotenc env list\n```\n\nLists encrypted environments in the current directory. Use `--all` to recursively list all environments across the project tree. Use `--json` for machine-readable output (`{ \"environments\": [...] }`).\n\n```\ndotenc env edit [environment]\n```\n\nOpens your system's default editor to modify the specified environment. To set a custom editor, use the `dotenc config editor` command. It will take precedence over your system's default editor. In a monorepo, `cd` to the directory containing the file before running `dotenc env edit`.\n\nExample:\n\n```\ndotenc config editor vim\n```\n\nCurrently supported `dotenc config` key: `editor`.\nYou can include editor arguments, for example: `dotenc config editor \"code --wait\"`.\nThe configured editor is trusted local input. Shell metacharacters are rejected\nand the command is launched without a shell, but editor-specific arguments can\nstill enable editor-native behavior. On POSIX, dotenc enforces mode `0700` on\n`~/.dotenc/` and `0600` on its `config.json` when reading or writing it. On\nWindows, home-configuration persistence fails closed because the runtime cannot\nsafely prevent reparse-point replacement; use `EDITOR` or `VISUAL`, with\n`notepad` as the platform fallback.\n\nFor development, the `dev` command always loads the required shared\n`development` environment and, when available, one accessible\n`personal.<profile>` overlay:\n\n```\ndotenc dev <command> [...args]\n```\n\nExample:\n\n```\ndotenc dev node app.js\n```\n\nPersonal profiles are discovered only along the effective ancestor chain (or\nonly in the current directory with `--local-only`). Access is tested by the\nrecipient fingerprint against your available private keys; `.dotenc/*.pub`\nfilenames are human-readable aliases and do not choose a namespaced\n`personal.<profile>` profile.\n\n- One accessible profile is selected automatically.\n- Several accessible profiles prompt in an interactive terminal. In\nnon-interactive use, pass `--profile <name>` .\n- `--profile alice` means the`personal.alice` environment.\n- No personal environment is a healthy state: `dev` runs with`development` only.\n- A requested missing/inaccessible profile, or discovered profiles with no\naccessible candidate, warns and continues with `development` only. Add`--strict` to make that personal-profile failure fatal.\n- `development` is always required, even without`--strict` .\n\n```\ndotenc dev --profile alice bun run start\ndotenc dev --profile alice --strict bun run start\n```\n\nThe `personal.*` namespace is a breaking replacement for legacy personal\nenvironments named directly after a key alias. When no namespaced personal\nprofile is selected, `dotenc dev` may print a read-only warning about an\naccessible environment that matches the former convention. The warning is only\na migration hint: `dev` never auto-loads or modifies the candidate, because an\nunprefixed environment may be legitimate. This legacy hint requires the exact\n`.dotenc/<name>.pub` alias to exist and validate, its fingerprint to be a\nrecipient in every effective `.env.<name>.enc` layer, and every layer to decrypt\nand authenticate successfully. For example, this remains valid:\n\n```\ndotenc run -e alice bun run test\n```\n\nMigrate a personal environment in the current directory explicitly:\n\n```\ndotenc env rename alice personal.alice\ndotenc dev --profile alice bun run test\n```\n\nFor a profile layered from the project root through the current directory, migrate every source layer in that effective chain with one reviewed operation:\n\n```\ndotenc env rename alice personal.alice --all-layers\n```\n\nUse `--all-layers` from a nested directory even when the only source is a\nsingle ancestor layer; the default command looks only in the current directory.\n\nThe command shows the source and destination paths and asks for confirmation.\nA non-interactive caller must pass `--yes`; that flag skips only the prompt, not\nvalidation, exclusive destination creation, or verification. Without\n`--all-layers`, `env rename` follows other single-environment commands and acts\nonly in the current directory. `--all-layers` does not scan unrelated sibling\npackages.\n\nThis is a cryptographic rename, not a filesystem move. dotenc decrypts the\nsource, emits a version 2 destination using `personal.alice` as AAD and a fresh\nciphertext IV, and preserves the recipient entries exactly. Every destination\ninode is created inside a private same-parent quarantine, published without\noverwrite by a hard link, and parsed and decrypted under its new name. Its\nprivate recovery link remains until source cleanup is complete. Before deleting\nany source inode, dotenc moves every source into a private same-parent\nquarantine, verifies its identity, content, and permissions, and re-verifies all\ndestinations. Before removing each destination recovery link, dotenc proves the\nlive path still names the verified inode or restores that inode exclusively. A\nlive source path recreated concurrently is never overwritten or deleted by\ncleanup.\n\nFor `--all-layers`, all destinations are verified before source cleanup starts,\nbut multiple filesystem operations cannot be atomic across directories. A\nwrite or verification failure keeps every source and attempts to remove any\ndestinations created by that invocation. If source cleanup fails partway, all\nverified destinations remain, already removed sources stay removed, and the\nremaining sources stay at their old or reported quarantine paths; the command\nexits non-zero and lists the state. If an unexpected object blocks exclusive\nrestoration, or quarantine restoration cannot be proven, the affected\nquarantine path is reported and every verified destination is retained as a\nrecovery copy. If a source vanishes\nbefore quarantine, its unresolved path is reported and the verified destination\nis kept. If an exclusive destination restore is blocked, its private recovery\npath is kept and reported. Review `git diff`,\nthen either remove the remaining legacy sources to finish, or restore tracked\nsources from Git and remove the new destinations to roll back. A failed\nbest-effort destination cleanup can leave both names and must be resolved before\nretrying because the destination is never overwritten. Git cannot restore an\nuntracked source; after partial cleanup, its verified destination is the\nremaining encrypted copy.\n\nFor explicit environment control, use `run`:\n\n```\ndotenc run --env <environment> <command> [...args]\n# or\ndotenc run -e <environment> <command> [...args]\n```\n\nExample:\n\n```\ndotenc run -e production node app.js\n```\n\nYou can also specify multiple environments:\n\n```\ndotenc run -e base,production node app.js\n```\n\nIn the example above, `production` will override any variables also present in `base`.\n\nIf you want `run` to fail when any selected environment cannot be loaded, use strict mode:\n\n```\ndotenc run --strict -e base,production node app.js\n```\n\nBefore spawning the command, dotenc rejects decrypted variables that can alter\nexecutable resolution, runtime loaders, shell startup, or GitHub Actions\ncontrol files. It prints variable names only, never values. All decrypted\n`DOTENC_*` names and the GitHub control-file names are reserved and cannot be\noverridden. For an exceptional trusted workflow, allow one non-reserved process\nvariable at a time with a repeatable flag:\n\n```\ndotenc run -e test --allow-process-env NODE_OPTIONS node app.js\ndotenc dev --allow-process-env NODE_OPTIONS npm start\n```\n\nThe exemption is exact and has no wildcard form. Bare commands are resolved\nagainst the original parent `PATH` before decrypted values are merged, so an\nallowed decrypted `PATH` cannot redirect the initial executable. The child\nnever receives `DOTENC_PRIVATE_KEY_BASE64`, legacy `DOTENC_PRIVATE_KEY`,\n`DOTENC_PRIVATE_KEY_PASSPHRASE`, or `DOTENC_ENV` from either source.\n\nIn a monorepo, `run` merges environment files from the project root down to the current directory (local values win). To load only from the current directory and skip ancestor directories:\n\n```\ndotenc run --local-only -e staging node app.js\ndotenc dev --local-only npm start\ndotenc whoami\n```\n\nShows your name, active SSH key, fingerprint, and the environments you have access to in this project.\n\n```\ndotenc update\n```\n\nRuns the appropriate update flow for your installation method (Homebrew, Scoop, npm, or manual binary instructions).\n\n```\ndotenc tools install-vscode-extension\ndotenc tools install-agent-skill\ndotenc tools install-agent-skill --force\ndotenc tools install-github-diffs \\\n  --environment .env.production.enc\n# Add --allow-fork only when the target repository is itself a fork.\n```\n\n- `install-vscode-extension` adds extension recommendations for supported editors and can open the extension page.\n- `install-agent-skill` installs the dotenc agent skill through the pinned`skills@1.5.22` runner via Bun. The source is an immutable GitHub archive at[`dotenc/skills@dc3245191988923fced07c63b31df8184a1d1853`](https://github.com/dotenc/skills/commit/dc3245191988923fced07c63b31df8184a1d1853) .\n- Bun's `bun` executable must be available on`PATH` ; the installer invokes its`bun x` package runner directly, and standalone dotenc binaries do not bundle\nBun.`--force` maps to non-interactive mode (`-y` ) for automation.\n- `install-github-diffs` creates a dedicated, least-privilege GitHub identity,\ngrants it only to explicitly selected environments (or`--all` ), uploads its\nprivate key without writing it to disk, and generates the immutable-SHA-pinned\nredacted pull-request diff workflow. It requires authenticated`gh` , clean\ntracked selected environments, and`--allow-fork` to acknowledge installation\nwhen the target repository is itself a fork. Fork pull requests can expose\nthe documented equality-oracle signal. See the[GitHub Actions runbook](https://github.com/dotenc/dotenc/blob/main/docs/GITHUB_ACTIONS.md#recommended-one-time-installer) .\n\nIn a real-world scenario, you will likely have multiple environments (e.g., `development`, `test`, `production`) and a team of developers who need access to these environments. Let's walk through how to set this up.\n\nAlice just joined your team and she needs access to the shared environments, except `production`. She already has an SSH key (because of course she does - she's a developer).\n\nShe sends you her public key (`~/.ssh/id_ed25519.pub`) — it's a public key, so Slack, email, or even a sticky note will do — and you grant her access:\n\n```\ngit checkout -b grant-alice-key\ndotenc key add alice --from-file alice.pub\ndotenc auth grant development alice\ndotenc auth grant test alice\ngit add .\ngit commit -m \"Grant alice access to development and test environments\"\ngit push\n```\n\nNow, Alice will be able to decrypt the `development` and `test` environments using her SSH key. No new tools for her to install, no custom keys to generate - just her existing SSH key.\n\nTo revoke a team member's key from every environment in the current repository\nstate (e.g., John), use `auth purge`:\n\n```\ndotenc auth purge john --yes\n```\n\nThis resolves John's alias to its key fingerprint, preflights every environment,\nrevokes and re-encrypts every affected environment, verifies the fingerprint is\ngone everywhere, and only then removes every `.pub` alias for that same key.\nThen, commit your changes:\n\n```\ngit checkout -b offboard-john\ngit add .\ngit commit -m \"Offboard John from all environments\"\ngit push origin offboard-john\n```\n\nOnce merged, John's private key can no longer decrypt the current environment\nfiles. `auth purge` does not rewrite Git history or erase existing clones, so\nthat key may still decrypt historical ciphertext addressed to it. Complete\noffboarding also requires removing repository access and rotating every\nexternal secret. If policy requires removing historical ciphertext, rewrite or\npurge the retained history and require fresh clones, while assuming old clones,\nmirrors, backups, and other copies remain readable.\n\nIf you only want to remove the key file without revoking environment access, use `key remove`:\n\n```\ndotenc key remove john\n```\n\nThis removes the `.pub` file only. Access to encrypted environments is left intact until you run `auth purge`.\n\n```\ndotenc auth list [environment]\n```\n\nLists all public keys that have access to the specified environment.\n\nUse `auth purge` to revoke a team member's key from every environment in the\ncurrent repository state and remove its public-key aliases in one operation:\n\n```\ndotenc auth purge <user> [--yes]\n```\n\nThis command:\n\n1. Resolves the named public-key alias to its fingerprint\n2. Validates and pre-decrypts every affected environment before making changes\n3. Revokes that fingerprint and re-encrypts each affected environment\n4. Rescans the project and deletes all `.pub` aliases for that fingerprint only\nafter complete verification\n\nUnreadable environments, a zero-recipient result, a failed rewrite, or a failed rescan make the command exit non-zero and retain the public key for a safe retry. Some environments may already have been rewritten after a mid-operation failure; the command never reports that state as successful.\n\nThis command does not rewrite Git history or erase existing clones. A holder of the purged private key may still decrypt historical ciphertext that names that key as a recipient.\n\nAfter running `auth purge`, also:\n\n- Remove the teammate's repository and organization access\n- Rotate external secrets (database passwords, API tokens, etc.); this remains necessary because retained copies cannot be recalled\n- Deploy updated configuration\n- If policy requires removing historical ciphertext, rewrite or purge retained Git history and require fresh clones, while treating old clones, mirrors, backups, and other copies as still readable\n\n```\ndotenc env delete [environment] [--yes]\n```\n\nDeletes an environment file in the current directory. In a monorepo, `cd` to the directory containing the file first.\n\n```\ndotenc env rotate [environment]\n```\n\nRotates the data key for a single environment in the current directory. In a monorepo, `cd` to the directory containing the file first.\n\n```\ndotenc env rotate --all [--yes]\n```\n\nRotates the data key for all environments in one step — recursively discovers and rotates every `.env.*.enc` file under the project tree. Useful for periodic key rotation or after a security event.\n\nCI runners and build servers need their own identity to decrypt environments. The approach is the same as local development: generate a key, grant access, and provide the private key at runtime.\n\nCreate an Ed25519 key pair for your CI environment. This example creates a\npasswordless key; if you choose a passphrase-protected key, also set\n`DOTENC_PRIVATE_KEY_PASSPHRASE` in your CI provider:\n\n```\nssh-keygen -t ed25519 -f ci_key -N \"\" -C \"ci\"\n```\n\nThis produces two files: `ci_key` (private) and `ci_key.pub` (public).\n\nRegister the public key in the project and grant it access to the environments CI needs:\n\n```\ndotenc key add ci --from-ssh ./ci_key\ndotenc auth grant test ci\ndotenc auth grant production ci\ngit add .\ngit commit -m \"Add CI key and grant access to test and production\"\ngit push\n```\n\nBase64-encode the private key file and store the result as a secret environment\nvariable named `DOTENC_PRIVATE_KEY_BASE64` in your CI provider:\n\n```\nbase64 < ci_key | tr -d '\\n'\n```\n\n`DOTENC_PRIVATE_KEY` with the raw private key text is still supported for\nbackwards compatibility, but new provider setup should use\n`DOTENC_PRIVATE_KEY_BASE64`.\n\nIf this private key is passphrase-protected, also set:\n\n```\nDOTENC_PRIVATE_KEY_PASSPHRASE=<your-passphrase>\n```\n\nOnce stored, delete the local private key file:\n\n```\nrm ci_key\n```\n\nThe public key (`ci_key.pub`) can also be deleted — it's already tracked inside `.dotenc/ci.pub`.\n\nWith `DOTENC_PRIVATE_KEY_BASE64` set (and `DOTENC_PRIVATE_KEY_PASSPHRASE` when\nusing an encrypted key), dotenc will automatically pick up the key. No `~/.ssh`\ndirectory required:\n\n```\ndotenc run -e test npm test\ndotenc run -e production node app.js\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v6\n      - uses: actions/setup-node@v6\n        with:\n          node-version: 24\n      - run: npm ci\n      - uses: dotenc/setup-action@v1\n      - uses: dotenc/run-action@v1\n        with:\n          environment: test\n          command: npm test\n        env:\n          DOTENC_PRIVATE_KEY_BASE64: ${{ secrets.DOTENC_PRIVATE_KEY_BASE64 }}\n          DOTENC_PRIVATE_KEY_PASSPHRASE: ${{ secrets.DOTENC_PRIVATE_KEY_PASSPHRASE }}\n```\n\ndotenc also ships reusable GitHub Actions for common CI patterns:\n\n- `dotenc/setup-action@v1` installs the CLI.\n- `dotenc/run-action@v1` runs one command under`dotenc run --strict` .\n- `dotenc/export-action@v1` exports an explicit allowlist to later\nsteps through`$GITHUB_ENV` .\n- `dotenc/write-file-action@v1` writes one decrypted value to a`0600` file for file-shaped credentials.\n- `dotenc/diff-action@v1` produces redacted semantic pull-request diffs. Its\nprivileged automatic workflow must use the hardened full-SHA-pinned setup\ngenerated by`dotenc tools install-github-diffs` , not the moving wrapper ref.\n\nThis lets GitHub keep only the dotenc bootstrap secret(s) in GitHub while\nprovider tokens live in an encrypted dotenc environment for jobs that actually\nrun on GitHub. Store the bootstrap key as `DOTENC_PRIVATE_KEY_BASE64`. If the\nbootstrap key is encrypted, also store `DOTENC_PRIVATE_KEY_PASSPHRASE`.\nSee [docs/GITHUB_ACTIONS.md](https://github.com/dotenc/dotenc/blob/main/docs/GITHUB_ACTIONS.md) for examples.\n\nThe redacted diff workflow has its own narrowly granted identity stored as\n`DOTENC_DIFF_PRIVATE_KEY_BASE64`; do not reuse or replace the ordinary CI\nbootstrap identity for it.\n\nEncrypted files are opaque in GitHub's native diff, so dotenc can add a redacted semantic report to each pull request. Install the hardened workflow with a dedicated, narrowly granted identity:\n\n```\ndotenc tools install-github-diffs \\\n  --environment .env.production.enc\n```\n\nThe report intentionally exposes variable names, recipient changes, and a\nchanged/unchanged equality signal. Install it only when that disclosure is\nacceptable for every pull-request author. Repositories that GitHub reports as\nforks require an explicit `--allow-fork` acknowledgement.\n\nThe action posts or updates one comment that looks like this:\n\n*Environment modified · `.env.production.enc`*\n\n```\n~ DATABASE_URL\n+ OPENAI_API_KEY\n- LEGACY_TOKEN\n~ ci-old → ci-new\n+ ci-production\n- contractor-john\n```\n\n*Data key rotated · `.env.development.enc`*\n\n`+` means added or granted, `-` means removed or revoked, and `~` means\nchanged or renamed. A data-key-only rotation verified through the dedicated\ndiff recipient gets the compact entry shown above. Formatting-only edits and\nsame-key ciphertext churn publish no report; with comments enabled, the action\nremoves its stale bot-owned report comments. Reports contain variable names and\naccess metadata, never variable values.\n\nThe generated workflow is pinned to an immutable action commit and never\nchecks out pull-request code into the privileged reporting job. See the\n[GitHub Actions runbook](https://github.com/dotenc/dotenc/blob/main/docs/GITHUB_ACTIONS.md)\nfor the security boundary, fork policy, and manual setup.\n\nSome CI/CD providers need extra setup because build steps, environment resolution, or secret storage work differently from a generic shell pipeline.\n\n- [GitHub Actions](https://github.com/dotenc/dotenc/blob/main/docs/GITHUB_ACTIONS.md) — use a dedicated GitHub Actions\nkey, then run commands, export allowlisted variables, or write file-shaped\ncredentials from encrypted dotenc environments.\n- [Expo / EAS](https://github.com/dotenc/dotenc/blob/main/docs/EXPO_EAS.md) — choose one lean path: EAS cloud builds with\nan EAS dotenc identity, or GitHub local builds with a GitHub dotenc identity.\n- [Vercel](https://github.com/dotenc/dotenc/blob/main/docs/VERCEL.md) — use a dedicated Vercel dotenc identity for\nVercel-owned cloud builds, then wrap the Vercel build command.\n- [Netlify](https://github.com/dotenc/dotenc/blob/main/docs/NETLIFY.md) — use a dedicated Netlify dotenc identity for\nNetlify-owned cloud builds, then wrap the Netlify build command.\n- [Cloudflare](https://github.com/dotenc/dotenc/blob/main/docs/CLOUDFLARE.md) — choose the trust boundary for Pages Git\nbuilds, Pages Direct Upload, Workers Builds, or external Wrangler deploys.\n- [Coolify](https://github.com/dotenc/dotenc/blob/main/docs/COOLIFY.md) — add\ndotenc to the application's existing Dockerfile, Railpack, or Nixpacks image,\nthen keep decryption at runtime when possible.\n- [Railpack](https://github.com/dotenc/dotenc/blob/main/docs/RAILPACK.md) —\ncompose the CLI image as a generic build or deploy layer without replacing\nthe auto-detected application runtime.\n- [Nixpacks](https://github.com/dotenc/dotenc/blob/main/docs/NIXPACKS.md) —\nsupport existing Nixpacks deployments with a pinned standalone binary;\nprefer Railpack for new generated-image deployments.\n- [Provider helpers roadmap](https://github.com/dotenc/dotenc/blob/main/docs/PROVIDER_HELPERS_ROADMAP.md) — track planned\npresets, provider plugins, provider CLIs, and the criteria for revisiting\nbuilder images.\n\ndotenc keeps key management minimal by design. Your SSH keys are your identity - dotenc just uses them.\n\nExisting **filesystem private keys** stay in `~/.ssh/` and are read in place.\n**Public keys** are stored in your project's `.dotenc/` folder, derived from the corresponding private keys.\n\nWhen the 1Password CLI 2.x (`op`) is installed and authenticated, dotenc can use\nSSH Key items without additional configuration. `dotenc init` and interactive\n`dotenc key add` show local keys immediately. Choose **Use a key from\n1Password (experimental)** under **Actions** to load public key metadata; a\ntemporary loading group is then replaced by account groups backed by stable\naccount IDs, so accounts and duplicate item titles remain unambiguous. For\nscripts, `--private-key` and `--from-private-key` accept a qualified\n`1password:<account-id>:<vault-id>:<item-id>` selector and load its provider\nmetadata directly.\n\nAfter a 1Password key is selected or successfully used, dotenc stores a\ndisposable machine-local locator under `~/.cache/dotenc` (or the platform cache\ndirectory). It contains only the public-key fingerprint and opaque account,\nvault, and item IDs—never key material, names, account URLs, or project paths.\nLater commands can go directly to one fingerprint-verified `op read` instead of\nrescanning every account and SSH item. Invalid or mismatched entries are\nevicted; transient CLI, timeout, and authorization failures preserve the\nlocator and fail the current operation without starting a full provider scan.\n\nAfter an interactive 1Password selection, dotenc also offers to save an\nunencrypted private-key copy in `~/.ssh`. The default remains locator-only. If\nyou explicitly opt in, dotenc fingerprint-verifies the retrieved key, chooses a\nnon-conflicting `id_<algorithm>_1password_<fingerprint>` filename, and writes it\nwith mode `0600`. This avoids future 1Password authorization and provider\nlatency, but expands private-key exposure from 1Password-managed memory access\nto a persistent local file.\n\nLocal keys keep priority during decryption. If none matches an environment,\nlocal commands such as `run`, `dev`, environment edit/decrypt, and access\nrotation can ask `op` for one fingerprint-matched private key. 1Password may\nshow its native authorization dialog at that point. After `op read` returns,\nthe key remains only in the dotenc process: it is not written to disk, persisted\nin project files, or forwarded to a wrapped command or its environment.\n`dotenc whoami` likewise consults 1Password only when no project identity\nmatches a local key.\n\nGit `textconv` may use an already cached locator and show the same authorization\ndialog, but it never performs full 1Password discovery. Without a valid cached\nlocator it immediately preserves the encrypted diff content.\n\nSee [1Password SSH key connector](https://github.com/dotenc/dotenc/blob/docs/ONEPASSWORD_CONNECTOR.md) for the full\nbehavior and security boundaries.\n\ndotenc supports the following SSH key types:\n\n- Ed25519\n- RSA (2048-bit or larger)\n\nThese types are widely supported and provide strong security guarantees.\n\n**Note:** dotenc can use passphrase-protected SSH keys when `DOTENC_PRIVATE_KEY_PASSPHRASE` is set. In interactive flows (`dotenc init` and interactive `dotenc key add`), selecting a passphrase-protected key also offers an optional passwordless copy flow (for example `id_ed25519_passwordless`). If you prefer a dedicated passwordless key, you can generate one with:\n\n```\nssh-keygen -t ed25519 -N \"\"\ndotenc key add [name] [--from-private-key <name-or-selector>] [--from-ssh <path>] [-f, --from-file <file>] [-s, --from-string <pem_string>]\n```\n\nAdds a public key into the project (`.dotenc/<name>.pub`).\n\n- `--from-ssh <path>` — Derive the public key from an SSH key file (private or public). Supports both Ed25519 and RSA keys.\n- `--from-private-key <name-or-selector>` — Choose a discovered private-key\ncandidate by name or qualified selector.\n- `-f, --from-file <file>` — Read a public (or private) key from a PEM file.\n- `-s, --from-string <pem_string>` — Use a PEM string directly.\n- No arguments — Interactive mode: choose a discovered SSH key, create a local key, or paste a PEM public key.\n- Key names may contain letters, numbers, dots (`.` ), hyphens (`-` ), and underscores (`_` ).\n\n```\ndotenc key list\n```\n\nLists all public keys in the project, showing each key's name and algorithm.\n\n```\ndotenc key remove [name]\n```\n\nRemoves the public key file from the project (`.dotenc/<name>.pub`). Does not revoke environment access. To fully offboard a key — revoking access from all environments and deleting the file — use `auth purge` instead.\n\ndotenc works in monorepos out of the box. Run `dotenc init` once at the repository root to create a shared `.dotenc/` folder and a root-level environment. Subdirectory packages can then have their own `.env.*.enc` files that overlay the root.\n\n**How environment loading works:**\n\n- `dotenc run` walks from the project root to the current directory, loading and\nmerging each requested environment.`dotenc dev` does the same for required`development` and its selected accessible`personal.<profile>` . Local values\noverride root values.\n- Use `--local-only` to load only the current directory's environments, skipping ancestor layers.\n\n**Creating, editing, rotating, and deleting environments:**\n\nAll `env` write commands operate on the current directory. `cd` to the target directory first:\n\n```\n# Create an environment in a package subdirectory\ncd packages/web\ndotenc env create staging\n\n# Edit, rotate, or delete that same file\ndotenc env edit staging\ndotenc env rotate staging\ndotenc env delete staging\n```\n\n**Listing environments:**\n\n```\ndotenc env list        # list environments in the current directory\ndotenc env list --all  # recursively list all environments in the project\n```\n\n**Batch operations cover the whole tree:**\n\n```\ndotenc env rotate --all --yes  # rotate all .env.*.enc files recursively\ndotenc auth purge alice --yes  # revoke alice from all envs in the project\n```\n\nFor convenience, you can setup your `package.json` file like this:\n\n```\n  // ...\n  \"scripts\": {\n    \"dev\": \"dotenc dev tsx src/app.ts\",\n    \"start\": \"dotenc run -e production node dist/app.js\",\n    \"test\": \"dotenc run -e test vitest\"\n  }\n```\n\nAlternatively, the `DOTENC_ENV` variable can be used to set the environment, so the `-e` option can be omitted. For example:\n\n```\n  export DOTENC_ENV=\"production\"\n  dotenc run node app.js\n```\n\n`DOTENC_ENV` selects the environment for dotenc itself and is removed before\nthe wrapped child command starts.\n\nThe CLI checks for new versions when you run `dotenc dev` and prints a notification when an update is available. Native Linux packages use their package manager's update channel instead.\n\nFor npm installations, `dotenc dev` also shows a one-time notice if Node's\nOpenSSL version predates the reviewed certificate-processing fix. Commands\ncontinue normally. Check your Node.js or distribution security updates;\nvendor backports may already include the fix. Automatic checks and notices are\nskipped on Windows, where secure home-configuration persistence is unavailable.\n\nWhen a clone looks right but the local workflow does not, run:\n\n```\ndotenc doctor\n```\n\nThe default scan follows the same effective scope as `dotenc dev`: project\nroot through the current directory. Use `--local-only` for only the current\ndirectory, or `--all` for a bounded recursive audit from the project root.\n`--profile alice` diagnoses the `personal.alice` suffix explicitly; it is not a\npublic-key alias lookup and cannot be combined with `--all`.\n\nNo personal profiles is healthy. Several accessible personal profiles is also\nhealthy; doctor reports that `dotenc dev` will prompt in an interactive\nterminal. Warnings remain exit `0` by default so normal developer flow stays\nusable; add `--strict` when warnings should fail automation.\n\nDoctor is read-only and offline. It does not repair files, fetch Git history,\ninvoke 1Password, open an authorization prompt, or decrypt environment\ncontent. It checks bounded envelope metadata and matching wrapped data keys in\nmemory, zeroes unwrapped keys, and inspects plaintext `.env` filenames and Git\nstate without reading plaintext file contents.\n\nHuman output stays compact and copyable:\n\n```\n✓ development          2 layers, data key decryptable.\n! personal.alice       A tracked personal profile was deleted from the working tree.\n  Paths: .env.personal.alice.enc\n  Run: git -C . --literal-pathspecs restore -- .env.personal.alice.enc\n\n0 errors · 1 warning · 4 checks passed\n```\n\nOn Windows, recovery lines are labeled `Run (PowerShell)` and use PowerShell\nliteral quoting. JSON recovery commands remain shell-neutral argv arrays on\nevery platform.\n\nExit codes are stable:\n\n- `0` — the scan completed without errors; warnings are allowed unless`--strict` is set.\n- `1` — errors were found, or`--strict` promoted one or more warnings.\n- `2` — the invocation was invalid or the scan/evidence could not complete.\n\nUse `dotenc doctor --json` for one versioned JSON object. `schemaVersion: 1`\naccompanies `command`, `complete`, `scope`, optional project metadata, typed\n`findings`, passed checks, `summary`, and `exitCode`. Finding paths are\nproject-relative and recovery commands are argv arrays, not shell strings. The\nreport never includes plaintext variable names or values, plaintext file\ncontents, ciphertext, wrapped data keys, private-key material or paths, cached\nprovider IDs, or raw provider exceptions.\n\nFor a recovery finding, a missing or empty `commands` array means doctor could\nnot establish a safe command from current local evidence; it is not permission\nto guess. A fresh `dotenc env create personal.<profile>` suggestion appears\nonly when complete, non-shallow local history finds no recoverable revision,\nand the message states that the new environment starts empty and cannot\nrecover old values. Doctor never fetches history to change that conclusion.\n\nBefore uploading a generated build or publish directory, scan it for likely secret leaks:\n\n```\ndotenc doctor artifacts dist\n```\n\nThe scan fails on plaintext `.env` files, private-key headers, and any active\ndotenc bootstrap value found in a regular artifact file. Bootstrap variable\nnames alone are warnings because a runtime reference can be intentional.\nEncrypted `.env.*.enc` files and `.env.example`, `.env.sample`, and\n`.env.template` files are not treated as plaintext environments.\n\nTo compare an application secret without putting its value on the command line, pass only its environment-variable name. The option is repeatable:\n\n```\ndotenc doctor artifacts .vercel/output \\\n  --secret-name DATABASE_URL \\\n  --secret-name OPENAI_API_KEY \\\n  --strict\n```\n\nEach selected name must identify a value already present in the doctor process\nenvironment whose UTF-8 representation is between 8 bytes and 1 MiB. The scan\ncompares literal values and common JSON/JavaScript string escapes, URL encoding,\nbase64/base64url, hexadecimal, and fully Unicode-escaped representations. Value\nmatches are errors; name-only matches are warnings. The same size bounds\napply to active dotenc bootstrap values so a value that cannot be compared\nsafely makes the scan incomplete instead of being silently skipped. Reports\ncontain only generic finding categories and artifact-relative paths—never the\nselected names or values. Paths containing a matched name or value representation\nare omitted. Use `--json` for the versioned machine-readable\nreport.\n\nGzip (`.gz` or gzip magic bytes) and Brotli (`.br`) assets are also inspected\nin memory. Decompression is limited to 16 MiB of compressed input and 32 MiB\nof expanded output per file; both count toward the 512 MiB scan budget.\nBrotli decoding requires a runtime exposing the CVE-2026-111497 fix; otherwise\n`.br` files make the scan incomplete (exit `2`) and gzip/plain-file scanning\ncontinues. Use a patched Node.js release or the current standalone dotenc binary.\nRecognized unsupported archives (including ZIP and tar), nested compression,\nmalformed compressed files, and exceeded limits return exit `2`. Scan an\nunpacked build directory before packaging; the command never extracts files.\n\nRun after the build has finished. This is a finite pattern check, not proof that a build contains no secrets: arbitrary string splitting, mixed/nested encodings, encryption, unknown container formats, and transformations outside the supported representations still need review. It does not decrypt dotenc environments; selected application values must already be available to the scanner. At most 128 names and 16 MiB of total search patterns are supported.\n\nThe scanner reads regular files through bounded, no-follow file handles. It\ndoes not follow symbolic links, and it exits `2` instead of claiming success\nwhen an entry is unsafe, changes during inspection, cannot be read, or exceeds\na file, directory, entry, or byte limit. Exit `1` means a high-confidence leak\nwas found, or `--strict` promoted a warning; exit `0` means the bounded scan\ncompleted without errors.\n\ndotenc is a Git-native encryption layer designed for teams who want encrypted environment files committed alongside their code. It does not aim to replace centralized secret managers like Vault or Doppler — it serves a different operational model.\n\n| Capability | dotenc | SOPS (+ age) | Vault | Doppler | \n|---|---|---|---|---|\n| Git-native encrypted files | ✅ | ✅ | ❌ | ❌ | \n| Uses existing SSH identity | ✅ | ❌ (age / PGP) | ❌ | ❌ | \n| No external service required | ✅ | ✅ | ❌ | ❌ | \n| Environments versioned with code | ✅ | ✅ | ❌ | ❌ | \n| Centralized runtime secret API | ❌ | ❌ | ✅ | ✅ | \n| Dynamic / short-lived secrets | ❌ | ❌ | ✅ | ❌ | \n| Built-in org policy engine | ❌ | ❌ | ✅ | ✅ | \n| Requires running infrastructure | ❌ | ❌ | ✅ | ❌ | \n\n- If you require centralized policy enforcement\n- If your compliance mandates HSM-backed key storage\n- If you need runtime secret injection via remote API", "url": "https://wpnews.pro/news/show-hn-dotenc-git-native-encrypted-environments-powered-by-your-ssh-keys", "canonical_source": "https://github.com/dotenc/dotenc", "published_at": "2026-11-27 19:49:24+00:00", "updated_at": "2026-11-27 20:13:36.153675+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents"], "entities": ["dotenc", "AES-256-GCM", "Ed25519", "RSA", "Git"], "also_reported_by": [], "takeaway": "dotenc encrypts each environment with its own random 256-bit data key under AES-256-GCM and wraps that key with developers' existing RSA or Ed25519 SSH public keys, so encrypted .env files can be committed and decrypted on the fly without a third-party secrets service.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-dotenc-git-native-encrypted-environments-powered-by-your-ssh-keys", "markdown": "https://wpnews.pro/news/show-hn-dotenc-git-native-encrypted-environments-powered-by-your-ssh-keys.md", "text": "https://wpnews.pro/news/show-hn-dotenc-git-native-encrypted-environments-powered-by-your-ssh-keys.txt", "jsonld": "https://wpnews.pro/news/show-hn-dotenc-git-native-encrypted-environments-powered-by-your-ssh-keys.jsonld"}}