First Secret
Create a vault, log in with your GPG key, store an encrypted secret, and read it back. By the end you will have a working vault and know the core secret store / secret get commands.
Prerequisites
Section titled “Prerequisites”- dotsecenv installed (Installation)
- A GPG key available (run
dotsecenv identity createif you need one)
-
Initialize the config
The config records where your vault lives and which identity you log in as:
Terminal window dotsecenv init configTo point at a specific vault path, pass
-v:Terminal window dotsecenv init config -v ./vault -
Initialize the vault
Create the encrypted vault file:
Terminal window dotsecenv init vault -
Log in
Record a signed login proof in the config. Always log in by fingerprint:
Terminal window dotsecenv login <FINGERPRINT>To find your fingerprint:
Terminal window gpg --list-keys --with-colons you@example.com | awk -F: '/^fpr:/ { print $10; exit }' -
Store a secret
Store a database password. Values are read from stdin, the only way to write to a vault:
Terminal window echo "super-secret-db-password" | dotsecenv secret store DATABASE_PASSWORD -
Read it back
Terminal window dotsecenv secret get DATABASE_PASSWORD# Output: super-secret-db-passwordRun
secret getwith no name to list keys (never values):Terminal window dotsecenv secret get -
Store a namespaced secret
Use namespaces to organize secrets by environment. The namespace lowercases and the key uppercases on store:
Terminal window echo "prod-password" | dotsecenv secret store prod::DATABASE_PASSWORDecho "staging-password" | dotsecenv secret store staging::DATABASE_PASSWORD -
Inspect and validate
vault describeshows identities and secret keys:Terminal window dotsecenv vault describevalidateruns a structural sanity check on the vault and config:Terminal window dotsecenv validate
Expected Result
Section titled “Expected Result”- A vault file holding your secrets, encrypted at rest with your GPG key
dotsecenv secret get DATABASE_PASSWORDreturns the valuedotsecenv vault describelists your identity and the secret keys, including the namespaced onesdotsecenv validateexits cleanly
Auto-loading into your shell
Section titled “Auto-loading into your shell”To export these secrets automatically when you cd into a project, add a .secenv file and install the shell plugin. That flow lives in Reloading Secrets and Getting Started; a minimal .secenv looks like:
DATABASE_PASSWORD={dotsecenv}Variations
Section titled “Variations”Interactive secret input
Section titled “Interactive secret input”For sensitive secrets, avoid piping to prevent history leaks:
dotsecenv secret store API_KEY# Type or paste your secret, then Ctrl+DReading from files
Section titled “Reading from files”dotsecenv secret store SSH_PRIVATE_KEY < ~/.ssh/private_keyMultiple vaults
Section titled “Multiple vaults”Store secrets in a project-specific vault:
dotsecenv init vault -v ./secrets/vaultecho "local-secret" | dotsecenv secret store -v ./secrets/vault LOCAL_SECRETTroubleshooting
Section titled “Troubleshooting”secret get fails to decrypt?
Your GPG fingerprint must be a recipient. Confirm you logged in with the right key:
dotsecenv vault describeWrong secret value?
Secrets are versioned. Get the latest:
dotsecenv secret get --last DATABASE_PASSWORDNext Steps
Section titled “Next Steps”- Reloading Secrets: auto-load secrets into your shell with
.secenv - Share a Secret: share secrets with teammates
- Revoke Access: remove someone’s access to secrets