| title | Keep .env and secret files at mode 600 | ||||||
|---|---|---|---|---|---|---|---|
| domain | security | ||||||
| tags |
|
||||||
| status | published | ||||||
| lang | en | ||||||
| source | uncledad96-glitch | ||||||
| created | 2026-07-23 | ||||||
| updated | 2026-07-23 | ||||||
| confidence | 0.9 |
API keys in .env are world-readable. Other users or leaked backups expose tokens.
Editors and echo key= > .env create mode 644 by default. umask is too open.
umask 077
touch .env
chmod 600 .env
# after any edit
chmod 600 .env secrets/* SECRETS.local.md 2>/dev/null || true
# git hygiene
grep -q '^\.env$' .gitignore || echo '.env' >> .gitignoreLoad without printing:
set -a
source ./.env
set +astat -c '%a %n' .env
# expect 600- Never commit
.env. PreferSECRETS.local.mdmode 600 outside the repo when possible. - Redact secrets in logs (see log-redaction lesson).