1. OS-Level Hardening
πΉ Minimal Installation β Install only necessary packages. Avoid GUI on servers unless required.
πΉ Update Regularly β Apply security patches promptly using apt update && apt upgrade
(Debian) or yum update
(RHEL).
πΉ Disable Unused Services β Use systemctl disable --now <service>
for unnecessary daemons.
πΉ Enable SELinux or AppArmor β Use setenforce 1
(SELinux) or aa-enforce
(AppArmor) for MAC enforcement.
πΉ Filesystem Hardening β Mount /tmp
, /var/tmp
, and /home
with noexec
, nosuid
, and nodev
.
2. User & Authentication Security
πΉ Enforce Strong Passwords β Use PAM (pam_pwquality.so
) and MFA for user authentication.
πΉ Disable Root Login β Set PermitRootLogin no
in /etc/ssh/sshd_config
.
πΉ Limit User Privileges β Implement sudo
with least privilege and restrict shell access (chsh -s /sbin/nologin
).
πΉ Use SSH Key Authentication β Replace password-based logins with key-based authentication (ssh-keygen -t ed25519
).
3. Network & Firewall Hardening
πΉ Enable Firewall β Use ufw
, firewalld
, or iptables
to restrict traffic. Example:
bashufw allow ssh
ufw allow 443/tcp
ufw enable
πΉ Disable Unused Ports β Check open ports using netstat -tulnp
or ss -tulnp
.
πΉ Enable Fail2Ban β Prevent brute-force attacks on SSH and web services.
πΉ Use VPN or Jump Hosts β Restrict direct server access by implementing WireGuard/OpenVPN and a bastion host.
πΉ Configure TCP Hardening β Add to /etc/sysctl.conf
:
bashnet.ipv4.tcp_syncookies = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.accept_source_route = 0
4. Application & Service Security
πΉ Use Web Application Firewall (WAF) β Deploy ModSecurity or Cloudflare for web-facing apps.
πΉ Run Services in Containers/Sandbox β Use Docker with minimal privileges (--no-new-privileges
flag).
πΉ Enforce HTTPS Everywhere β Use Let’s Encrypt or a commercial CA for SSL/TLS.
πΉ Log & Monitor Everything β Use auditd
, syslog
, and SIEM solutions like ELK or Splunk.
5. Storage & Data Security
πΉ Encrypt Data at Rest β Use LUKS
for full disk encryption or eCryptfs
for home directories.
πΉ Secure Backups β Encrypt backups (gpg
, openssl enc
) and store them in secure locations.
πΉ Apply File Integrity Monitoring (FIM) β Use AIDE or Tripwire to detect unauthorized changes.
πΉ Use Immutable Logs β Mount logs with chattr +i
to prevent tampering.
6. Advanced Security Techniques
πΉ Enable Kernel Hardening β Implement Grsecurity or Kernel Lockdown Mode.
πΉ Use Mandatory Access Controls (MAC) β SELinux/AppArmor profiles for service isolation.
πΉ Deploy IDS/IPS β Use Suricata or Snort for intrusion detection/prevention.
πΉ Implement SIEM/SOC Monitoring β Automate threat detection using OSSEC, Wazuh, or commercial solutions.
πΉ Automate Compliance Audits β Use OpenSCAP or Lynis for continuous compliance checking.