๐Ÿ“Š We use cookies & analytics to improve your experience. Learn more
Latest

Cybersecurity Fundamentals Module 4 ยท Lesson 10 of 15

0% Exit to course

Module 4 ยท Hands-on defence Lesson 10 of 15

Hardening a Linux server

Learning objective

Most breaches use a door somebody left open: a default password, an exposed database, an old package. Hardening is closing the obvious doors first, and it is measurable.

The concept

Disable root login over SSH as well, and keep the SSH port and firewall on an allow list - the goal is fewer ways in, not a longer password.

Write the changes down as a checklist. A hardening step you cannot repeat on the next server is a one-off, not a control.

Terminal
# key-only SSH
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' \
  /etc/ssh/sshd_config
sudo systemctl restart ssh

# updates + firewall
sudo apt update && sudo apt upgrade -y
sudo ufw default deny incoming
sudo ufw allow 22/tcp && sudo ufw allow 80,443/tcp
sudo ufw enable

# remove default accounts nobody uses
sudo deluser --remove-home pi 2>/dev/null || true

Worked example

Disabling password login for SSH and allowing only keys removes the single most attacked door on the internet.

Your practice task

Harden one VM: key-only SSH, update packages, and enable the firewall - then list what you changed.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

Disable root login over SSH as well, and keep the SSH port and firewall on an allow list - the goal is fewer ways in, not a longer password.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task โ€” do them and the final project brief writes itself.