Linux Security Hardening
Security is not an afterthought. Here are the essential steps to secure a Linux server.1. SSH Hardening
SSH is the front door to your server. Lock it down.Disable Root Login
Never allow direct root login. Log in as a user and usesudo.
Edit /etc/ssh/sshd_config:
Use SSH Keys (Disable Passwords)
Passwords can be brute-forced. Keys are cryptographic.- Generate Key (On your local machine):
ssh-keygen -t ed25519 - Copy ID:
ssh-copy-id user@server_ip - Disable Password Auth (On server):
Edit
/etc/ssh/sshd_config: - Restart SSH:
sudo systemctl restart ssh
2. Firewall (UFW)
Uncomplicated Firewall (UFW) is the easiest way to manageiptables.
3. Fail2Ban
Automatically ban IPs that show malicious signs (e.g., too many failed password attempts)./etc/fail2ban/jail.local:
4. File Permissions
Ensure sensitive files are not world-readable.Key Takeaways
- Never use passwords for SSH; use Keys.
- Always run a firewall (UFW).
- Disable root login.
- Use Fail2Ban to stop brute-force attacks.
- Keep your system updated (
apt update && apt upgrade).
Next: Docker Crash Course →