Overview
The project uses SOPS (Secrets OPerationS) with age encryption to securely store secrets in Git. All secrets insecrets/*.yaml are encrypted at rest and can only be decrypted with the age private key.
Quick Start
Generate age encryption key:Initial Setup
Generate Age Key
Thesops-init command (scripts/sops-init.sh:4-18) generates a new age key pair:
Location: ~/.config/sops/age/keys.txt
What it does:
-
Check for existing key:
-
Generate new key pair:
-
Display instructions:
Configure SOPS
The repository includes.sops.yaml configuration:
- All files matching
secrets/*.yamlwill be encrypted - Encrypted with the specified age public key
- Only holders of the private key can decrypt
Working with Secrets
Create Encrypted Secret
Create and edit a new secret:- Encrypts all values with age
- Keeps keys in plaintext
- Adds metadata (key fingerprint, version)
Edit Encrypted Secret
Edit existing encrypted file:- Decrypts content using your private key
- Opens in your editor (unencrypted)
- Re-encrypts on save
View Secret (Read-Only)
Decrypt and display without editing:Extract Specific Value
Get single value from encrypted file:Encrypted File Format
After encryption, files look like:- Data: Encrypted values with AES256-GCM
- Metadata: Encryption method, recipients, timestamps
- MAC: Message authentication code for integrity
Kubernetes Integration
Create Secret from SOPS File
Decrypt and apply to cluster:Use in Manifest Generation
In nixidy modules, you can reference SOPS-encrypted files:Team Collaboration
Share Access with Team Member
-
Team member generates their key:
-
Update
.sops.yaml: -
Re-encrypt all secrets:
-
Commit changes:
Revoke Access
- Remove public key from
.sops.yaml - Re-encrypt all secrets with
sops updatekeys - Ensure removed key holder deletes their private key
Security Best Practices
Protect Your Private Key
Never commit~/.config/sops/age/keys.txt to Git!
Back up securely:
Rotate Secrets Regularly
Verify Encryption
Before committing, ensure secrets are encrypted:Troubleshooting
”Failed to get the data key”
Cause: Private key not found or doesn’t match Solution:“no age key found in SOPS_AGE_KEY_FILE”
Cause: SOPS can’t find your key Solution: Set environment variable~/.bashrc:
“MAC mismatch”
Cause: File corrupted or tampered with Solution: Restore from Git historyKey Lost/Corrupted
If you lose your private key:- Regenerate with
sops-init - Update
.sops.yamlwith new public key - Manually re-create secrets (you’ll need plaintext versions)
- Encrypt with SOPS
~/.config/sops/age/keys.txt!