Skip to content

Appendix B: Quick commands

# What listens, and who owns it
sudo ss -tlnp
# Which compose file started each container
for c in $(docker ps -q); do docker inspect -f '{{.Name}} {{index .Config.Labels "com.docker.compose.project.config_files"}}' $c; done
# External reachability (from laptop / hotspot)
nc -zv -w5 <host> <port>
# Is an RDS endpoint public?
dig +short <endpoint>
# Pending Postgres settings (incl. ones waiting for restart)
psql -c "select sourcefile, name, setting, applied from pg_file_settings"
# Unknown DB roles
psql -c "select rolname, rolsuper, rolcanlogin from pg_roles where rolname !~ '^(pg_|rds)'"
# What the DB sees as the client address
psql -c "select inet_client_addr()"
# Compare two secrets without printing them (compare the hashes yourself, never share them)
printf '%s' "$SECRET" | sha256sum
# Generate a secret
openssl rand -base64 48 | tr -d '/+=\n' | cut -c1-40