M
Security Knowledge Base The Ethical Hacker's Command Handbook
๐Ÿ“š All Modules (15) ๐Ÿ“ฅ PDF Download Library (30)
DOCUMENTATION MODULES
01. Nmap Reconnaissance & Scanning 02. Linux Essentials for Practitioners 03. Metasploit Framework Fundamentals 04. Searchsploit & Vulnerability Research 05. Web Application Security Fundamentals 06. Network Security & Packet Analysis 07. Privilege Escalation (Educational Labs) 08. Credential Security & Hash Analysis 09. Controlled Exploitation & Post-Exploitation 10. Reconnaissance & Surface Enumeration 11. Linux System Security & Defensive Hardening 12. Security Automation with Python & Scripting 13. AI & Agentic Workflows in Cybersecurity 14. Security Tools Command Index & Quick Reference 15. Penetration Testing Methodology & Authorization
โ† Return to Portfolio
terminal LINUX SYSTEM ADMINISTRATION & SECURITY LEARNING

Linux System Security & Defensive Hardening

Hardening Linux hosts, firewall configuration (UFW), SSH key enforcement, and authentication log auditing.

Overview

Linux System Security & Defensive Hardening addresses the proactive configuration, auditing, and maintenance of Linux hosts to minimize attack surfaces. Hardening transforms an installation from a permissive default configuration into a resilient bastion host through access control enforcement, firewall policies, cryptographic SSH configuration, and audit logging.

Core Concepts

Tools & Requirements

UFW (Uncomplicated Firewall), systemd/journalctl, OpenSSH server, and core GNU security auditing commands.

Commands & Practical Examples

1. Host Firewall Hardening with UFW

Configure default incoming drop rules, allow only encrypted administrative access, and activate the firewall:

BASH // FIREWALL CONFIGURATIONUFW
$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing
$ sudo ufw allow 22/tcp comment 'SSH Management'
$ sudo ufw enable
$ sudo ufw status verbose

2. OpenSSH Daemon Hardening

Apply security directives in /etc/ssh/sshd_config to disable password authentication and root login:

CONFIG // SSHD SECURITY DIRECTIVES/ETC/SSH/SSHD_CONFIG
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
X11Forwarding no
MaxAuthTries 3
BASH // TEST & RELOAD SSHDSYSTEMCTL
$ sudo sshd -t && sudo systemctl reload ssh

3. Authentication & System Log Auditing

Inspect authentication failure logs and identify brute-force patterns:

BASH // LOG INVESTIGATIONJOURNALCTL & AUTH.LOG
$ sudo journalctl -u ssh -n 50 --no-pager
$ grep "Failed password" /var/log/auth.log | tail -n 20

4. Auditing World-Writable Files and System Permissions

Scan the filesystem for dangerously permissive files and directories:

BASH // PERMISSION AUDITFIND
$ find / -type f -perm -0002 2>/dev/null
$ find /etc -type f -perm -o+w 2>/dev/null

Practical Workflow

  1. Network Minimization: Run ss -tulpn to identify all listening services and terminate unnecessary daemons.
  2. Firewall Enforcement: Apply UFW default-deny policy and whitelist only necessary ports.
  3. SSH Hardening: Restrict SSH to key-based authentication and non-root users.
  4. Filesystem Audit: Check permissions across /etc, /var, and shared directories.
  5. Log Verification: Review authentication logs regularly to ensure audit pipelines are functioning.

Common Mistakes & Troubleshooting

Security Considerations & Scoping

Hardening configurations should be tested on staged or virtual systems before deployment to production environments to prevent service disruption.

Further Reading & TryHackMe Paths