Skip to content
EncryptTechBD
Home Industries Our Work Blog Pricing About Contact Discuss Your Project
বাংলা (BN)
Website & Infrastructure 6 min read

Linux server hardening checklist for lean IT teams

A practical Linux hardening checklist covering patching, SSH, sudo, services, logging, backups and the evidence to collect at each step.

E
EncryptTechBD · 0 comments
Computer memory modules
Photo: Charlie Belvin Designs / StockSnap

A Linux server is rarely compromised by an advanced exploit alone. It is compromised by an old package, a password-only SSH login, an application running as root, or a service that was opened to the internet for a one-off task and never closed. Hardening is the discipline of removing those easy paths before someone else finds them.

This checklist is written for a small team that manages its own servers, whether on a VPS, a colocation rack or a cloud account. Work through it in order, record evidence for each item and schedule the work in a maintenance window. Do not treat it as a one-time audit. The checklist is most useful as a quarterly routine.

Prerequisites

  • An accurate inventory: hostname, owner, purpose, operating system, exposure to the internet and data classification.
  • Out-of-band access: console access through the provider, not only SSH, so a firewall mistake does not lock you out.
  • A tested backup and a rollback plan: a snapshot is not a backup until you have restored from it.
  • A change window and an approver: hardening changes can break applications, so agree the window and the rollback trigger.
  • A baseline capture: open ports, installed packages, users, cron jobs and running services before you change anything.

Capture the baseline with commands such as ss -tulpn, systemctl list-unit-files --state=enabled, getent passwd and crontab -l, and store the output with the change record.

Assign every section to a named owner before you start. In a small team one person may own several sections, but the name and the review date should still be recorded.

1. Patch and package baseline

  • Enable automatic security updates, or a weekly patch window with an owner.
  • Remove packages and services the server does not need. Every extra package is extra attack surface.
  • Confirm that package repositories are official and signed. Remove third-party repositories you no longer use.
  • Track kernel and library versions, and reboot when a kernel update requires it.
  • Keep an inventory of end-of-life software and a dated plan to replace it.

2. Accounts and authentication

  • One named account per administrator. No shared root login.
  • Use sudo with specific permissions rather than unlimited root access for everyone.
  • Disable direct root login over SSH and require key-based authentication with a passphrase on the key.
  • Remove or lock accounts for former staff and unused service accounts.
  • Review accounts with UID 0 and any account with a valid shell.
  • Set a strong password policy for local console access, even when SSH uses keys.
  • Require MFA for the bastion host or the cloud console that controls the server.

3. SSH and remote access

  • Set PermitRootLogin no, PasswordAuthentication no and PubkeyAuthentication yes.
  • Restrict access with AllowUsers or AllowGroups instead of allowing every account to connect.
  • Limit MaxAuthTries and idle timeout values.
  • Bind SSH to a private interface or require a VPN or bastion for administrative access.
  • Treat tools such as Fail2ban as noise reduction, not as a substitute for key-only access.
  • Revoke user keys when someone leaves or a laptop is lost, and rotate host keys only during a planned rebuild or a suspected compromise.

4. Services, ports and network exposure

  • Default-deny inbound traffic with the host firewall, then allow only required ports.
  • Close database, cache, admin panels and monitoring ports to the public internet. Bind them to localhost or a private network.
  • Disable or remove unused services, including print, mail and file-sharing daemons.
  • Document every public port with a business reason and an owner.
  • Restrict outbound traffic where practical, especially from web servers and containers.
  • Review cloud security groups and network ACLs at the same time as the host firewall.

5. Filesystem and permissions

  • Set a restrictive default umask, typically 027 for servers.
  • Mount /tmp, /var/tmp and /dev/shm with noexec, nosuid and nodev where applications allow it.
  • Find and review world-writable files and directories.
  • Review SUID and SGID binaries and remove unnecessary ones.
  • Separate application data, logs and operating system files onto appropriate partitions.
  • Use file integrity monitoring on critical binaries and configuration files.

6. Logging and monitoring

  • Send authentication, sudo, cron and application logs to a central location the server cannot silently delete.
  • Enable and tune audit rules for privilege changes, sensitive file access and unexpected process execution.
  • Synchronise time with a reliable source so correlations work.
  • Alert on repeated login failures, successful logins from new locations and changes to firewall rules.
  • Define log retention based on business and regulatory needs, and test that logs are actually arriving.

7. Web and application layer

  • Run each application under a dedicated, unprivileged user.
  • Keep the runtime, framework, CMS and plugins patched, and remove unused plugins and themes.
  • Disable directory listing and verbose error pages in production.
  • Terminate TLS with a current configuration and renew certificates automatically.
  • Restrict upload directories so they cannot execute code.
  • Keep secrets out of the web root and out of version control.

8. Backups and recovery

  • Follow the 3-2-1 pattern: three copies, two media types, one off-site or offline.
  • Encrypt backups and restrict who can delete them.
  • Test a full restore, not just a file-level restore, at least quarterly.
  • Record the recovery time and compare it with the business requirement.
  • Keep a restore runbook that a second person can follow.

Evidence and verification

For each section, keep a short evidence pack: the command output, a screenshot of the relevant configuration, the date, the person who checked it and any exception with a review date. A checklist without evidence becomes a document that everyone signs and nobody verifies.

Common mistakes

  • Hardening a server without a rollback path and breaking production.
  • Disabling password login before confirming that key access works for every admin.
  • Opening a database port "temporarily" for a report and forgetting to close it.
  • Relying on a single security tool while leaving default accounts active.
  • Treating a vulnerability scan as proof that the server is hardened.
  • Skipping the restore test because the backup job reports success.

Metrics to track

  • Percentage of servers with key-only SSH and no direct root login.
  • Median days to apply critical patches.
  • Percentage of hosts sending logs to the central collector.
  • Number of public ports without a documented owner.
  • Backup restore test pass rate and measured restore time.
  • Number of stale accounts removed in the last quarter.

Where this fits in our work

If you need a hardened baseline without adding another full-time role, start with Managed Technology & Cybersecurity. The pricing page explains how we scope server and infrastructure work. For the web layer, read the malware prevention checklist for business websites.

Sources

Services that deliver this

Want this implemented properly?

Pricing →

Every engagement starts with a written scope. If a requirement is outside it, we quote it separately before starting.

Responses (0)

No comments yet. Add the first one below.

Leave a response

Your email address will not be published. Required fields are marked *.

Keep reading

More field notes