How to Share a Config File Safely: A Redaction Checklist for .env, YAML and nginx

How to Share a Config File Safely: A Redaction Checklist for .env, YAML and nginx

"Can you send me your config?" is one of the most common requests when debugging, and one of the most common ways secrets leak. Config files gather passwords, API keys and tokens over time, and they're often shared in a hurry. This guide gives you a quick, reliable way to share a config that's useful for debugging without exposing anything.

What to redact

Look forExample key names
Passwordspassword, DB_PASS, pwd
API keys and tokensapi_key, SECRET_KEY, token, bearer
Connection stringsDATABASE_URL=postgres://user:pass@host/db (the password is inside)
Private keys and certificates-----BEGIN PRIVATE KEY-----, ssl_certificate_key paths
Webhook URLsSlack or Discord webhooks, payment callbacks with tokens
Cloud credentialsAccess key IDs and secret keys, service-account JSON
Possibly sensitiveInternal hostnames, IPs, email addresses, customer IDs

Redact consistently

Keep the key names and structure, and replace only the values. That way the person helping can still see what's configured.

.env

APP_ENV=production
APP_URL=https://example.com
DB_HOST=127.0.0.1
DB_USER=app
DB_PASSWORD=[REDACTED]
STRIPE_SECRET_KEY=sk_live_[REDACTED]
MAIL_PASSWORD=[REDACTED]

YAML

database:
  host: db.internal          # internal host, kept because it matters for the bug
  user: app
  password: "[REDACTED]"
redis:
  url: "redis://:[REDACTED]@cache.internal:6379/0"

nginx

server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate     /etc/ssl/example.crt;
    ssl_certificate_key /etc/ssl/[REDACTED].key;
    location /api/ {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Authorization "Bearer [REDACTED]";
    }
}

Tips: keep a recognisable prefix if it helps (sk_live_… vs sk_test_… tells someone which environment you're in); use the same placeholder everywhere; and if two values are equal, say so ("same as DB_PASSWORD") rather than revealing either.

A 60-second redaction routine

  1. Copy the file; never edit the real one.
  2. Search for: pass, secret, key, token, auth, :// and BEGIN.
  3. Replace values with placeholders.
  4. Read the whole file once top to bottom for anything the search missed.
  5. Share only the relevant section if the issue is in one block.

How to share it

Paste the redacted config into the code sharing tool, pick YAML, JSON, Bash or plain text, and send the link. Indentation is preserved (critical for YAML), lines are numbered for discussion, and links are unlisted. Unlisted isn't private, though: anyone with the link can read it, which is why redaction comes first.

Avoid pasting configs straight into chat apps: they can mangle indentation and keep a copy in channel history forever.

If a secret leaked

  1. Rotate or revoke it immediately at the provider (database, payment provider, cloud, email service). This is the only step that actually fixes the leak.
  2. Update your apps with the new value.
  3. Remove the shared copy: delete the message or request removal of the paste via the contact page.
  4. Check logs for unexpected use during the exposure window.

Prevent it next time

The same care applies to screenshots of dashboards and terminals: how to redact a screenshot.

Indentation-safe sharing for YAML, JSON, .env and nginx configs, with line numbers. Remove secrets first.

Share a redacted config

Frequently asked questions

What should I remove from a config file before sharing?

Passwords, API keys, tokens, private keys and certificates, database connection strings, webhook URLs with tokens, internal hostnames and IP addresses if they are sensitive, and any personal data.

What should I replace secrets with?

Clear placeholders that keep the format, such as DB_PASSWORD=[REDACTED] or api_key: "sk-...REDACTED". Keep the key names, so helpers can still see the structure.

I accidentally shared a secret. Is deleting it enough?

No. Assume it was copied. Rotate or revoke the secret immediately at the provider, then delete the shared copy and check logs for misuse.

Is it safe to commit .env files to Git?

No. Add .env to .gitignore and commit a .env.example with placeholder values instead.

Related articles

← All guides