🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Web & Software Development › Deployment: Servers, CI/CD, and Cloud Publishing › Lesson 3
TEC-WEB46-07 · Lesson 3 · 16 clock hours · lab

Linux Server Configuration and Hardening

Objective. Students apply baseline Linux server hardening steps—including disabling root SSH login, configuring UFW firewall rules, and enabling automatic security updates—on their provisioned VPS.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Why Server Hardening Matters

When you provision a fresh VPS, it arrives with reasonable defaults—but not secure ones. The root account is usually enabled for SSH, all ports may be reachable, and automatic security patching is often off. Attackers run automated scanners around the clock looking for exactly these conditions. Hardening is the process of reducing a system's attack surface by removing or restricting anything that is not required. This lesson walks you through three baseline steps every Linux administrator performs before a server is considered production-ready.

Securing SSH with sshd_config

SSH (Secure Shell) is the primary remote-access protocol for Linux servers. Its behavior is controlled by `/etc/ssh/sshd_config`. Two settings must be changed immediately on any new server.

PermitRootLogin no — The root account has unrestricted system access. Allowing direct root login over SSH gives an attacker a known username to target. Setting this to `no` forces all users to log in as a named, limited account and escalate privilege with `sudo` only when needed. This creates an audit trail and limits blast radius if credentials are stolen.

PasswordAuthentication no — Passwords can be guessed or brute-forced. Key-based authentication uses a cryptographic key pair: you keep the private key, the server holds the public key. Without the private key file, a password guess is useless. Disabling password authentication entirely eliminates brute-force as an attack vector. Important: confirm your SSH key is installed and working before you disable password auth, or you will lock yourself out of the server.

After editing the file, restart the SSH service with `sudo systemctl restart ssh` (Ubuntu uses the service name `ssh`). Verify the settings loaded by running `sudo sshd -T | grep -E 'permitrootlogin|passwordauthentication'`. The `-T` flag prints the effective configuration after parsing.

Configuring UFW (Uncomplicated Firewall)

UFW is a front-end for iptables included in Ubuntu. It lets you manage firewall rules in plain English rather than raw iptables syntax. A properly configured firewall is the single most effective control for reducing network exposure.

The correct approach is default deny inbound, allow only what is needed. For a typical web server you need three ports:

All other inbound connections should be dropped silently. UFW also maintains a default allow-outbound rule so your server can reach package repositories and external APIs without extra configuration.

Always add the SSH rule before enabling the firewall. Enabling UFW with default-deny and no SSH rule will immediately cut your remote session.

After enabling UFW, run `sudo ufw status verbose`. This displays each rule, the policy for incoming and outgoing traffic, and whether the firewall is active. Read this output carefully and compare it to your intended rule set before moving on.

Enabling Automatic Security Updates

Even a perfectly hardened server becomes vulnerable the moment a known CVE (Common Vulnerability and Exposure) is published for installed software. The `unattended-upgrades` package applies security patches automatically on a schedule, closing that window without requiring manual intervention every day.

On Ubuntu, install and configure it with `sudo apt install unattended-upgrades` and then `sudo dpkg-reconfigure -plow unattended-upgrades`. The main configuration file is `/etc/apt/apt.conf.d/50unattended-upgrades`. Open it and review the `Allowed-Origins` section: it controls which package repositories are eligible for automatic updates. The default includes the Ubuntu security pocket (`${distro_id}:${distro_codename}-security`), which is exactly what you want. Leave the full distribution upgrade lines commented out to avoid unexpected major changes.

You can trigger a dry run with `sudo unattended-upgrades --dry-run --debug` to confirm the service is configured correctly without actually installing anything.

Documenting Your Work

The lab log is not busywork. In a real environment, a change log is a legal and operational requirement. Record every command you ran, the before-and-after state of each configuration file, and the output of verification commands. Your instructor will review the log alongside a live port scan to confirm the technical controls are in place.

Safety and Professional Considerations

While this is software work with no electrical hazard, there are operational safety rules:

Following these practices is what separates a careful professional from someone who causes an outage.

Key terms8

Attack surfaceThe total set of points on a system where an unauthorized user could attempt to enter or extract data; hardening reduces it by disabling unnecessary services and ports.
sshd_configThe main configuration file for the OpenSSH server daemon, located at /etc/ssh/sshd_config; changes take effect after the SSH service is restarted.
PermitRootLoginAn sshd_config directive that controls whether the root account may authenticate over SSH; setting it to 'no' is a baseline hardening requirement.
Key-based authenticationAn SSH authentication method that uses a matched cryptographic key pair instead of a password, making brute-force attacks impractical.
UFW (Uncomplicated Firewall)A user-friendly command-line interface for managing iptables firewall rules on Ubuntu and Debian-based Linux systems.
Default deny policyA firewall stance in which all inbound connections are blocked unless a specific rule explicitly permits them; considered best practice for server security.
unattended-upgradesAn Ubuntu package that automatically downloads and installs security updates on a scheduled basis without requiring manual administrator action.
CVE (Common Vulnerabilities and Exposures)A public catalog of known security vulnerabilities in software, each assigned a unique identifier; unpatched CVEs are a primary target for attackers.
In class: Edit /etc/ssh/sshd_config to set PermitRootLogin no and PasswordAuthentication no, then restart the SSH service and verify the settings take effect. · Configure UFW to allow ports 22, 80, and 443 only, enable the firewall, and run ufw status verbose to confirm the rule set. · Enable unattended-upgrades on the Ubuntu server, review /etc/apt/apt.conf.d/50unattended-upgrades, and document the configuration in the lab log.
Materials: Student VPS from Lesson 2, OpenSSH client, UFW man page, Ubuntu Server documentation, CompTIA Linux+ study guide (security domain), lab log
Check: Instructor runs a remote port scan (nmap) against the student's VPS and reviews sshd_config live; root login and password auth must be disabled and only approved ports open. Lab log entry graded with rubric, 80% required.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

CompTIA Linux+ — Security
1. A student edits /etc/ssh/sshd_config and sets PermitRootLogin to no, then closes the file. What must the student do next for the change to take effect?
CompTIA Linux+ — Security
2. Which command displays the effective SSH server configuration—including values set by defaults—after sshd parses all configuration files?
CompTIA Linux+ — Security
3. A student wants to allow only SSH, HTTP, and HTTPS traffic inbound on their Ubuntu VPS and block everything else. In what order should they run UFW commands to avoid locking themselves out?
CompTIA Linux+ — Security
4. After enabling UFW on a server, which command confirms the active rules and the firewall's current status in a single output?
CompTIA ITF+ — Security Concepts
5. Why is PasswordAuthentication no considered a stronger security control than simply requiring a complex password for SSH login?
CompTIA Linux+ — Security
6. The unattended-upgrades package is configured on an Ubuntu server. Which repository pocket should be enabled in 50unattended-upgrades to ensure only security patches are applied automatically?
CompTIA Linux+ — Security
7. Before editing /etc/ssh/sshd_config on a production-like VPS, what precaution should an administrator take to enable quick recovery if a mistake locks them out over SSH?
CompTIA Linux+ — Security
8. An instructor runs nmap against a student's VPS and finds port 3306 (MySQL) open to the internet. The student claims MySQL is needed only by local web applications on the same server. What is the correct remediation?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.