How do you protect secrets on a Linux server?
IntermediateProductionFirewalls, MAC & Compliance
Answer
- Do not bake secrets into images or commit them to repos; fetch at runtime from Vault, AWS Secrets Manager/SSM, or use systemd credentials (
LoadCredential=). - File permissions
0600/0640owned by the service user, never world-readable. - Avoid passing secrets as command-line arguments (visible in
psand/proc/<pid>/cmdline); environment variables are visible in/proc/<pid>/environto root and the same user. - Use instance roles instead of long-lived cloud keys.
More on Firewalls, MAC & Compliance
How do ufw, firewalld, nftables and iptables relate?BeginnerConfigure ufw for a web server with SSH only from the office.BeginnerExplain firewalld zones and runtime vs permanent configuration.IntermediateWrite a minimal nftables ruleset for a server.AdvancedWhy are nftables preferred over iptables at scale?AdvancedHow do you avoid locking yourself out when changing remote firewall rules?Intermediate