Share a Secret
Share an encrypted secret with a teammate so they can decrypt it with their own GPG key.
Prerequisites
Section titled “Prerequisites”- dotsecenv configured with secrets (Your First Secret)
- Teammate’s GPG public key imported into your keyring
-
Get your teammate’s GPG public key
Your teammate exports their public key:
Terminal window # Teammate runs thisgpg --armor --export teammate@example.com > teammate-public.ascThey send you the
teammate-public.ascfile (this is safe to share publicly). -
Import their public key
Terminal window gpg --import teammate-public.ascVerify the import:
Terminal window gpg --list-keys teammate@example.comNote the fingerprint (40-character hex string).
-
Share specific secrets
The
secret sharecommand automatically adds the identity to the vault if needed:Share a single secret:
Terminal window dotsecenv secret share DATABASE_PASSWORD TEAMMATE_FINGERPRINTOr share multiple secrets:
Terminal window dotsecenv secret share API_KEY TEAMMATE_FINGERPRINT -
Send the vault file
The vault is now encrypted for both of you. Commit and push:
Terminal window git add vaultgit commit -m "Share secrets with teammate"git pushOr send the vault file directly.
-
Teammate sets up access
Your teammate:
Terminal window # Pull the updated vaultgit pull# Configure dotsecenv to use the vaultdotsecenv init configdotsecenv login THEIR_FINGERPRINT# Retrieve the shared secretdotsecenv secret get DATABASE_PASSWORD
Expected Result
Section titled “Expected Result”After sharing:
- The secret is encrypted with both your key and your teammate’s key
- Either of you can decrypt it independently
- The vault shows both identities in
available_to
dotsecenv vault describe# Vault 1 (~/.config/dotsecenv/vault):# Identities:# - You <you@example.com> (YOUR_FINGERPRINT)# - Teammate <teammate@example.com> (TEAMMATE_FINGERPRINT)# Secrets:# - DATABASE_PASSWORDVariations
Section titled “Variations”Share multiple secrets at once
Section titled “Share multiple secrets at once”Share all secrets in a namespace:
# Share all prod secretsdotsecenv secret share "prod::*" TEAMMATE_FINGERPRINTShare with multiple teammates
Section titled “Share with multiple teammates”Share with each teammate (identities are added automatically):
dotsecenv secret share DATABASE_PASSWORD ALICE_FINGERPRINTdotsecenv secret share DATABASE_PASSWORD BOB_FINGERPRINTVerify GPG key trust
Section titled “Verify GPG key trust”Before sharing, verify the key is trusted:
gpg --edit-key TEAMMATE_FINGERPRINT# At the gpg> prompt, type: trust# Select trust level 4 (full) or 5 (ultimate)# Type: quitSharing workflow for teams
Section titled “Sharing workflow for teams”Recommended workflow:
- One person initializes the vault with all secrets
- Collect GPG public keys from all team members
- Add identities for each team member
- Share secrets with appropriate team members
- Commit the vault to version control
- Team members pull and configure their local setup
How It Works
Section titled “How It Works”When you share a secret:
- dotsecenv decrypts the secret value using your GPG key
- Generates a new random session key (AES-256-GCM)
- Encrypts the value with the session key
- Encrypts the session key for each authorized identity
- Appends the new encrypted entry to the vault
The original value remains unchanged—a new entry is added. This is the append-only design.
Troubleshooting
Section titled “Troubleshooting”“Key not found” error
Make sure the key is imported:
gpg --list-keys FINGERPRINTIf missing, ask your teammate to send their public key again.
“Not trusted” warning
Sign the key to trust it:
gpg --sign-key FINGERPRINTTeammate can’t decrypt
Verify they’re using the correct fingerprint:
# Teammate runs:gpg --list-secret-keys --keyid-format longThe fingerprint must match exactly.
Next Steps
Section titled “Next Steps”- Revoke Access — Remove someone’s access to secrets
- Security Model — Understand the encryption model