Linux Server Hardening Checklist 2026: A Complete Security Guide
A practical, step-by-step Linux server hardening guide covering SSH lockdown, firewall rules, kernel tuning, audit logging, automatic patching, and CIS benchmark alignment for Ubuntu and RHEL.
Why Server Hardening Matters
A default Linux installation is designed for ease of use, not security. Default configurations include SSH root login enabled, no firewall rules, unnecessary services running, weak password policies, and no audit logging. Each of these is an attack vector. Hardening closes these gaps systematically.
Pre-Hardening: Document Your Current State
Step 1: System Updates and Automatic Patching
Apply All Updates
Enable Automatic Security Updates
Ubuntu:
RHEL/Rocky:
Step 2: SSH Hardening
SSH is the most attacked service on any Linux server.
Edit /etc/ssh/sshd_config:
Set Up Key-Based Authentication
Install Fail2Ban
Create /etc/fail2ban/jail.local:
Step 3: Firewall Configuration
UFW (Ubuntu)
firewalld (RHEL)
iptables Rate Limiting
Step 4: User Account Security
Password Policy
Edit /etc/security/pwquality.conf:
minlen = 14
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
maxrepeat = 3
Account Lockout
Add to /etc/pam.d/common-auth:
auth required pam_faillock.so preauth deny=5 unlock_time=900
auth required pam_faillock.so authfail deny=5 unlock_time=900
Sudo Hardening
Remove Unused Accounts
Step 5: Kernel Hardening
Create /etc/sysctl.d/99-hardening.conf:
Step 6: Audit Logging
Configure auditd
Add rules to /etc/audit/rules.d/hardening.rules:
Step 7: Disable Unnecessary Services
Step 8: File System Security
Secure Mount Options in /etc/fstab
tmpfs /tmp tmpfs defaults,noexec,nosuid,nodev 0 0
tmpfs /var/tmp tmpfs defaults,noexec,nosuid,nodev 0 0
File Permissions
Step 9: Intrusion Detection
AIDE (File Integrity Monitor)
Lynis (Security Auditor)
Step 10: Monthly Verification Script
CIS Benchmark Alignment
| CIS Control | Guide Section | |-------------|---------------| | 1.1 Filesystem Configuration | Step 8 | | 2.1 Special Purpose Services | Step 7 | | 3.1-3.5 Network Configuration | Steps 3, 5 | | 4.1-4.2 Logging and Auditing | Step 6 | | 5.1 SSH Configuration | Step 2 | | 5.2-5.4 User Accounts | Step 4 | | 6.1 File Permissions | Step 8 |
Frequently Asked Questions
Should I change the SSH port?
Changing the port from 22 to a non-standard port reduces automated scanner noise by 90%+. It's not true security — any targeted attacker will find the port — but it dramatically reduces brute-force attempts and log noise, making real attacks easier to spot.
How often should I run hardening checks?
Run automated checks monthly. Review audit logs weekly. Apply security patches as soon as they're released — automatic security updates handle this. Run Lynis quarterly for a comprehensive audit.
Does kernel hardening affect performance?
Most kernel hardening parameters have negligible performance impact. The exception is ptrace_scope, which can break debugging tools. Use ptrace_scope = 1 on development servers instead of 2.
What about containers and cloud servers?
Container hosts need additional hardening — Docker daemon configuration, runtime security, and namespace restrictions. Cloud VMs should follow this guide plus cloud-specific controls like security groups, IAM roles, and encrypted volumes.