Top 10 Linux Configurations Every Organization Should Lock Down
Published · Updated
The configuration files and parameters that most directly affect your Linux security posture: what goes wrong with each, and how to keep it right.
1. Sudoers configuration (/etc/sudoers)
File location: /etc/sudoers, /etc/sudoers.d/*
If one file causes the most security headaches on Linux, it's /etc/sudoers. It controls who gets root and how. Get it wrong and you've handed the keys to whoever happens to be logged in.
What usually goes wrong
NOPASSWD entries added "temporarily" for debugging stay for years. Wildcards like /usr/bin/* let users run anything as root. A group-based rule can quietly give hundreds of developers full sudo, and nobody notices until someone stumbles on it.
NOPASSWDeverywhere because typing passwords is "annoying"- Wildcards that look harmless but open privilege-escalation paths
- Copy-pasted entries whose purpose nobody remembers
- No logging, so you can't tell who used sudo for what
Enforcement best practices
- Require passwords for all sudo operations unless there's a documented reason
- Use explicit command paths instead of wildcards
- Turn on command logging with
log_inputandlog_output - Regularly review who has sudo access and why
- Use
visudofor all changes to prevent syntax errors
2. PAM configuration (/etc/pam.d/)
File location: /etc/pam.d/common-auth, system-auth, password-auth
Pluggable Authentication Modules (PAM) control how users authenticate. Weak PAM configuration can allow brute-force attacks, weak passwords or authentication bypasses.
Common risks
- No account lockout policy (
pam_faillock) - Weak password requirements (no
pam_pwqualityenforcement) - Password aging or history checks turned off
- No two-factor authentication module
Enforcement best practices
- Lock accounts after repeated failed attempts:
pam_faillock.so - Enforce strong passwords: minimum length 14+, with complexity requirements
- Keep password history to prevent reuse
- Consider MFA for privileged access
- Log all authentication attempts for the audit trail
3. Audit daemon (auditd.conf)
File location: /etc/audit/auditd.conf, /etc/audit/rules.d/*.rules
The Linux audit framework logs security-relevant events in detail. Without proper configuration you lose visibility into who did what and when, which matters for incident response and compliance.
Common risks
- Audit daemon not enabled or not running
- Too little disk space allocated, causing lost logs
- No rules for access to critical files (e.g.
/etc/passwd,/etc/shadow) - No monitoring of privilege escalation
Enforcement best practices
- Set
max_log_file_action = keep_logsto retain audit history - Monitor authentication events and privileged commands
- Watch sensitive system files with
-w <path> -k <key>rules - Make the audit configuration immutable until reboot with
-e 2as the last rule - Forward logs to a central SIEM for correlation
4. Kernel parameters (sysctl.conf)
File location: /etc/sysctl.conf, /etc/sysctl.d/*.conf
Kernel parameters control low-level behavior: network stack security, memory protections and process isolation. Defaults are often tuned for compatibility, not security.
Common risks
- IP forwarding enabled on systems that aren't routers
- Source-routed packets accepted, enabling spoofing
- ICMP redirects accepted, allowing route hijacking
- No SYN cookie protection against SYN floods
- Address space layout randomization (ASLR) disabled
Parameters to lock down
| Parameter | Purpose |
|---|---|
net.ipv4.ip_forward = 0 | Disable IP forwarding unless the system is a router |
net.ipv4.conf.all.accept_source_route = 0 | Reject source-routed packets |
kernel.randomize_va_space = 2 | Full ASLR for exploit mitigation |
kernel.dmesg_restrict = 1 | Restrict kernel log access to privileged users |
Remember that sysctl -w changes the running value without touching any file. Check the effective value, not only the configuration files.
5. Kernel module blacklisting (/etc/modprobe.d/)
File location: /etc/modprobe.d/blacklist.conf
Unneeded kernel modules widen the attack surface. Rarely used protocols, filesystems and drivers should be disabled.
Modules to consider disabling
dccp,sctp,rds,tipc: rarely used network protocolscramfs,freevxfs,hfs,hfsplus,jffs2: uncommon filesystemsudf: unless you mount optical mediausb-storage: on servers where USB storage is prohibitedfirewire-core: legacy interface with DMA attack vectors
6. SSH configuration (/etc/ssh/sshd_config)
File location: /etc/ssh/sshd_config
SSH is often the main remote access path. Defaults favor compatibility over security, leaving systems open to brute-force attacks and weak authentication.
Critical settings
| Setting | Purpose |
|---|---|
PermitRootLogin no | Never allow direct root login |
PasswordAuthentication no | Require key-based authentication |
PubkeyAuthentication yes | Enable public key authentication |
MaxAuthTries 3 | Limit authentication attempts |
ClientAliveInterval 300 | Time out idle sessions |
7. Permissions on sensitive files
Wrong permissions can expose sensitive data or allow unauthorized changes. These files need strict permissions:
| File | Mode | Why |
|---|---|---|
/etc/passwd | 644 | World-readable, writable only by root |
/etc/shadow | 640 or 000 | Password hashes must be protected |
/etc/ssh/sshd_config | 600 | SSH server configuration |
/var/log/auth.log | 640 | Authentication logs contain sensitive data |
8. Log rotation (/etc/logrotate.conf)
Without proper log rotation, systems can run out of disk space, or logs can disappear before anyone investigates. Set retention that balances storage against investigation needs.
Best practices
- Keep logs for at least 90 days, or longer if your compliance requirements say so
- Compress rotated logs
- Set maximum log sizes to prevent disk exhaustion
- Use
copytruncatefor applications that can't reopen log files - Forward critical logs to remote syslog or a SIEM before rotation
9. SELinux / AppArmor configuration
Mandatory Access Control (MAC) adds defense in depth beyond standard permissions. It contains compromised processes and limits the blast radius of a successful exploit.
Never disable MAC
Running SELinux or AppArmor in permissive mode while troubleshooting is acceptable. Disabling it leaves systems open to privilege escalation and lateral movement.
Enforcement requirements
- Run in enforcing mode in production
- Review policy violations and write custom policies where needed
- Never use
setenforce 0or disable AppArmor as a "fix" - Test policy changes in permissive mode before enforcing
10. Firewall configuration (iptables / nftables / firewalld)
Host-based firewalls are the last line of defense against network attacks. Default-allow policies or missing rules expose services that don't need to be reachable.
Default-deny configuration
- Start with a default DROP policy for the INPUT and FORWARD chains
- Allow only the services you need (SSH, application ports)
- Restrict SSH to specific source IP ranges where possible
- Log dropped packets for security monitoring
- Use connection state tracking to allow established connections
- Persist rules across reboots with your distribution's mechanism
Implementation strategy
Locking these down takes a systematic approach:
- Baseline definition: document the current state and define target configurations.
- Staged rollout: test changes outside production first.
- Automated enforcement: use configuration management to hold the desired state.
- Continuous checks: detect drift on every check cycle and fix it.
- Regular audits: confirm configurations still match policy.
With LEA Platform, each of these settings becomes a rule: the agent reads the raw configuration (for example cat /etc/ssh/sshd_config or values from /proc/sys) with read-only commands, and your server judges the output against the expected value. Rules can carry an opt-in remedy, such as sysctl -w net.ipv4.ip_forward=0, that runs when a check fails, followed by an automatic re-check.
Try LEA Platform on your own servers:
Start a free POC