Skip to content

Insights

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.

  • NOPASSWD everywhere 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_input and log_output
  • Regularly review who has sudo access and why
  • Use visudo for 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_pwquality enforcement)
  • 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_logs to 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 2 as 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

ParameterPurpose
net.ipv4.ip_forward = 0Disable IP forwarding unless the system is a router
net.ipv4.conf.all.accept_source_route = 0Reject source-routed packets
kernel.randomize_va_space = 2Full ASLR for exploit mitigation
kernel.dmesg_restrict = 1Restrict 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 protocols
  • cramfs, freevxfs, hfs, hfsplus, jffs2: uncommon filesystems
  • udf: unless you mount optical media
  • usb-storage: on servers where USB storage is prohibited
  • firewire-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

SettingPurpose
PermitRootLogin noNever allow direct root login
PasswordAuthentication noRequire key-based authentication
PubkeyAuthentication yesEnable public key authentication
MaxAuthTries 3Limit authentication attempts
ClientAliveInterval 300Time out idle sessions

7. Permissions on sensitive files

Wrong permissions can expose sensitive data or allow unauthorized changes. These files need strict permissions:

FileModeWhy
/etc/passwd644World-readable, writable only by root
/etc/shadow640 or 000Password hashes must be protected
/etc/ssh/sshd_config600SSH server configuration
/var/log/auth.log640Authentication 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 copytruncate for 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 0 or 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:

  1. Baseline definition: document the current state and define target configurations.
  2. Staged rollout: test changes outside production first.
  3. Automated enforcement: use configuration management to hold the desired state.
  4. Continuous checks: detect drift on every check cycle and fix it.
  5. 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

Try it on your own servers.

30 days, up to 25 endpoints, every feature. We help you install it and agree on success criteria first.