Welcome to Linux Server Security
An evolving how-to guide for securing a Linux server that teaches you about security fundamentals and why they matter. This guide covers everything from SSH hardening to intrusion detection, helping you protect your server from unauthorized access and attacks.Getting Started
Learn the fundamentals and prepare your server for hardening
SSH Security
Secure your SSH server with public/private keys and configuration hardening
Network Security
Configure firewalls and intrusion detection systems
Auditing & Monitoring
Monitor your server and detect potential security threats
Why Secure Your Server
The moment a device becomes visible to the outside world, it becomes a target for bad actors. An unsecured server is a playground for attackers who want:- Access to your data
- To use your server as a node in large-scale DDOS attacks
- To covertly steal data without leaving traces
- To compromise your system for their nefarious purposes
What This Guide Covers
SSH Server Hardening
SSH Server Hardening
- Public/private key authentication
- SSH configuration best practices
- Two-factor authentication
- Removing weak encryption keys
Basic Security
Basic Security
- User access control (sudo/su)
- Application sandboxing with FireJail
- Secure password policies
- Automatic security updates
Network Protection
Network Protection
- Firewall configuration with UFW
- Intrusion detection with PSAD
- Application protection with Fail2Ban
- Collaborative security with CrowdSec
System Auditing
System Auditing
- File integrity monitoring with AIDE
- Anti-virus scanning with ClamAV
- Rootkit detection with Rkhunter
- Security auditing with Lynis
- Host intrusion detection with OSSEC
Advanced Hardening
Advanced Hardening
- Linux kernel sysctl parameters
- Web server security (nginx)
- Advanced security configurations
Guide Philosophy
This guide is intended to be followed in order, as some sections depend on previous configurations. However, you can skip sections that don’t apply to your use case.
What This Guide Is
- Work in progress - Continuously evolving with new security techniques
- Distribution agnostic - Applicable to most Linux distributions
- Practical and actionable - Includes copy-paste commands and real examples
- Educational - Explains the “why” behind security measures
What This Guide Is Not
- Not a Linux tutorial - Assumes basic Linux knowledge
- Not exhaustive - Covers server security, not all aspects like physical security
- Not one-size-fits-all - Your security needs may vary based on your threat model
Before You Start
Quick Navigation
Choose a Distribution
Pick the right Linux distribution for your server
Installation Requirements
Pre and post installation checklist
Automate with Ansible
Use Ansible playbooks to automate security hardening
Community & Contributions
This guide is open source and accepts contributions. If you find errors, have suggestions, or want to add new security techniques, please contribute on GitHub.For comprehensive industry-standard security benchmarks, also review the CIS Benchmarks after completing this guide.