Security Fundamentals
Understand Linux security principles and defense strategies.
Linux security isnβt one feature β itβs a discipline. The goal is to reduce risk by limiting what an attacker can do, detecting bad behavior early, and recovering quickly when something goes wrong.
Security Principles
- β’Least Privilege: Users and processes should have minimum necessary permissions
- β’Defense in Depth: Multiple layers of security controls
- β’Fail Secure: Systems should fail in a secure state
Threat Modeling (the practical version)
Before changing configs, decide what youβre defending against:
- β’What is the asset? (customer data, SSH access, API keys, production uptime)
- β’Who is the attacker? (internet scanners, insiders, compromised CI)
- β’What is the entry point? (SSH, web ports, exposed admin panels, weak creds)
- β’Whatβs the blast radius? (single host vs entire fleet, prod vs staging)
Attack Surface Inventory (quick checks)
# What ports are exposed?
$ ss -tulpn | head
# What services start at boot?
$ systemctl list-unit-files --type=service --state=enabled | head
# Who has sudo access?
$ getent group sudo
$ sudo -l
$ ss -tulpn | head
# What services start at boot?
$ systemctl list-unit-files --type=service --state=enabled | head
# Who has sudo access?
$ getent group sudo
$ sudo -l
Security Checklist
- β
Keep system updated (
apt update && apt upgrade) - β Use strong passwords and SSH keys
- β Configure firewall (iptables/ufw)
- β Disable unnecessary services
- β Monitor logs regularly
- β Set up intrusion detection (fail2ban)
What βgoodβ looks like (baseline)
- β’Patch hygiene: security updates applied quickly; reboot policy defined
- β’Strong auth: SSH keys, no root login, and no password auth (when possible)
- β’Minimal exposure: only required ports open; default deny inbound
- β’Logging: auth/service logs monitored; suspicious patterns alert
- β’Recovery: backups tested; secrets rotated; incident runbook exists
β Practice (20 minutes)
- List listening ports with
ss -tulpnand explain why each must be open. - Check who can use sudo (
getent group sudoandsudo -l). - Inspect authentication logs (
journalctl -u sshor/var/log/auth.log) and spot failed login attempts.