-
Notifications
You must be signed in to change notification settings - Fork 1
Secrets Management
Manage environment secrets across local and VPS environments. strut provides tools to generate, sync, diff, and validate .env files without manual SCP or copy-paste.
Since: v0.25.0 (init-secrets), v0.26.0 (secrets push/pull/diff/validate)
The secrets workflow has two complementary tools:
| Command | Purpose |
|---|---|
init-secrets |
Generate a populated .env from a .env.template
|
secrets push |
Upload local .env to VPS (secure SCP, mode 600) |
secrets pull |
Download .env from VPS to local |
secrets diff |
Compare local vs remote keys (values redacted) |
secrets validate |
Check all required_vars are present and non-empty |
Start from a stack's .env.template and auto-generate cryptographic secrets for password, token, and key variables:
strut my-app init-secrets --env prod
strut my-app init-secrets --env prod --dry-run # preview without writing
strut my-app init-secrets --env staging --force # overwrite existing values- Reads
stacks/<stack>/.env.template - Detects placeholder values (
changeme,xxxx, empty, etc.) - Auto-generates secrets based on key name patterns:
-
*SECRET*,*JWT*→ 32-byte hex -
*PASSWORD*→ 16-byte hex -
*SALT*→ 16-byte hex -
*TOKEN*,*KEY*(generic) → 24-byte hex -
*ENCRYPTION*→ 32-byte hex
-
- Respects generation hints in comments:
# Generate with: openssl rand -hex 64 MY_SECRET=changeme - Leaves API keys, domains, and URLs as-is (user must fill manually)
-
Never overwrites existing non-placeholder values (unless
--force) - Safe to re-run — only fills in missing/placeholder values
- Variables needing manual input (API keys, external URLs) are left untouched
These patterns are recognized as placeholders:
- Empty values
-
changeme,CHANGEME,Change-Me -
your-*,YOUR_* -
xxxx,XXXX -
replace-*,REPLACE_* -
todo,TODO,fixme,FIXME -
example,placeholder
Upload local .env to the VPS:
strut my-app secrets push --env prod
strut my-app secrets push --env prod --force # overwrite existing remote
strut my-app secrets push --env prod --dry-runBefore pushing, strut automatically validates required_vars (if the file exists). If any required variables are missing, the push aborts.
Download the remote .env to local:
strut my-app secrets pull --env prod
strut my-app secrets pull --env prod --force # overwrite local fileCompare local and remote env files without exposing values:
strut my-app secrets diff --env prodOutput shows:
- Changed — keys present in both but with different values
- Only in local — keys you have locally but not on VPS
- Only on remote — keys on VPS you don't have locally
Values are never displayed — only key names.
Check that all variables in required_vars are present and non-empty:
strut my-app secrets validate --env prod# 1. Create .env from template with generated secrets
strut my-app init-secrets --env prod
# 2. Fill in remaining values manually (API keys, domains)
nano .prod.env
# 3. Validate everything is set
strut my-app secrets validate --env prod
# 4. Push to VPS
strut my-app secrets push --env prod
# 5. Deploy
strut my-app release --env prodstrut looks for env files in this order:
-
stacks/<stack>/.<env>.env(stack-level) -
<project_root>/.<env>.env(project-level)
Remote path: <deploy_dir>/.<env>.env
| Tool | Purpose |
|---|---|
init-secrets |
Generate initial .env from template |
secrets push/pull |
Sync .env between local and VPS |
secrets diff |
Compare local vs remote |
keys env:* |
Rotate/validate individual env vars |
drift detect |
Detect config file drift (broader than just secrets) |
strut · v0.28.0 · Report an Issue
Getting Started
Core Concepts
Operations
- Deployment
- Ship and Rebuild
- GitHub Actions
- Remote Host Setup
- Provisioning
- Blue-Green Deploy
- Deploy Rollback
- Database Backups
- Secrets Management
- Stack Groups
- Lifecycle Hooks
- Notifications
- Key Rotation
- Drift Detection
- Domain and SSL
- Certificate Management
- Gateway Management
- Monitoring
- Volume Management
Advanced
- Security Posture
- VPS Audit and Migration
- Stack Validation
- Data Anonymization
- Debugging
- Local Development
Extending
Contributing