Linux server hardening checklist for small businesses
A Linux server hardening checklist for UK small businesses: updates, SSH, firewall, services, web server, logs and backups, in plain English with commands.
Server hardening means switching off everything your Linux server does not need and locking down what is left, so there are fewer ways for an attacker to get in. For a small business web server, the checklist comes down to seven areas: automatic security updates, key-only SSH sign-in, a firewall that only opens the ports you use, no unused services, a web server that hides secrets, logs kept for months, and backups stored somewhere else.
This guide is written so a business owner can follow the decisions and hand the technical steps to a developer or IT support. The commands assume Ubuntu or Debian, the most common choice for rented web servers, and differ slightly on other distributions.
What is server hardening, and why does it matter?
Server hardening is reducing a server's "attack surface": the number of programs, open ports, accounts and settings an attacker could use. A freshly rented server often ships with defaults chosen for convenience, such as password sign-in. Hardening swaps those for safer settings and removes what you do not need, before anyone finds it.
The UK's National Cyber Security Centre explains why speed matters in its vulnerability management guidance: most incidents start with attackers exploiting weaknesses that have already been made public, often soon after they are disclosed. A web server is on the internet all day, so it is scanned constantly. Hardening does not make it unbreakable, but it removes the easy wins that automated attacks look for.
What should I do before hardening a live server?
Make sure you cannot lock yourself out and can undo mistakes. Before changing anything, take a snapshot or full backup, confirm you have a second way in (most hosts offer a web console), and write down what the server runs: websites, databases, apps and scheduled jobs. Change one area at a time and test after each.
A few minutes of preparation saves hours:
- Snapshot or back up the whole server through your hosting provider.
- Check console access works, in case an SSH change goes wrong.
- List what runs on the server and which ports each thing needs. Most web servers need only 80 and 443 open to the world, plus SSH for administrators.
- Pick a quiet time for changes that restart services.
The Linux server hardening checklist
Work through the table in order. The first three rows block most automated attacks; the rest make an attack harder to hide and easier to recover from.
| Area | What to do | How to check |
|---|---|---|
| Security updates | Turn on automatic security updates; reboot when the kernel is updated | cat /etc/apt/apt.conf.d/20auto-upgrades; ls /var/run/reboot-required |
| SSH sign-in | Keys only, no password sign-in, no direct root password login | sudo sshd -T | grep -Ei 'passwordauth|permitroot' |
| Firewall | Allow only 80, 443 and SSH; deny everything else coming in | sudo ufw status verbose |
| User accounts | One named account per person, with sudo only where needed; remove leavers | getent group sudo; review /etc/passwd |
| Services | Remove or disable anything not needed; databases listen on localhost only | ss -tulpn |
| Web server | Block access to .env, .git and backups; HTTPS only; current TLS |
Request https://yourdomain/.env and expect 403 or 404 |
| File permissions | Web files owned by a deploy user, not writable by the web server except upload folders | ls -l on the web root |
| Logs | Keep important logs at least six months, ideally on another system | Check journalctl retention and log rotation |
| Backups | Automatic, off the server, and tested by restoring | Restore one file this month |
| Monitoring | Alerts for sign-ins, new ports, new users and keys, and disk space | Trigger a test alert |

How do I turn on automatic security updates on Ubuntu?
On Ubuntu Server, the unattended-upgrades package is installed by default and applies security updates once a day. Check it is enabled, decide how reboots will happen, and make sure someone notices when a reboot is waiting. Updates that need a restart do not protect you until the restart happens.
Ubuntu's automatic updates documentation explains the two lines that control it, in /etc/apt/apt.conf.d/20auto-upgrades:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
By default only the security pocket is enabled, so ordinary feature updates are not installed without you. Automatic reboot is off by default (Unattended-Upgrade::Automatic-Reboot "false";). You can turn it on and set a quiet time with Automatic-Reboot-Time, or keep it off and reboot by hand each week. Either is fine, as long as someone owns it.
The NCSC's vulnerability guidance also asks you to plan for the end of support: once a release stops getting security updates, upgrade it or keep it separated and closely watched. Check when your Ubuntu or Debian release reaches end of standard support and put the upgrade in the diary.
How should SSH sign-in be set up?
Use SSH keys instead of passwords, turn off password sign-in, and do not let anyone sign in directly as root with a password. Give each administrator their own account and key so you can remove one person without affecting others. Always test the change in a second session before closing the first.
Ubuntu's OpenSSH server documentation recommends ed25519 keys (ssh-keygen -t ed25519) and suggests putting your own settings in a file under /etc/ssh/sshd_config.d/, so they stay separate from system defaults. It also warns that a mistake can lock you out of a server you can only reach by SSH, so test with sudo sshd -t before restarting.
A minimal hardening file might contain:
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin prohibit-password
The sshd_config manual lists the defaults: password authentication is allowed unless you turn it off, and root is already limited to key sign-in (prohibit-password) by default on current OpenSSH. Our guide to stopping SSH brute force attacks covers the rest, including fail2ban and limiting who can connect.
Which ports and services should be open on a web server?
Only the ones the business needs. For most web servers that means 80 and 443 for the website, and SSH for administrators, ideally limited to known addresses. Databases, caches and admin panels should listen only on the server itself, not on the internet. Anything you do not recognise should be explained or removed.
To see what is listening, run ss -tulpn. Each line shows a port and the program behind it. Then set a firewall with a default of "deny incoming". On Ubuntu, ufw is the simplest option; it is installed but disabled by default according to Ubuntu's firewall documentation. Allow SSH before you enable it, or you will cut off your own session:
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
Remove software that is not used. A mail server, FTP service or old control panel that nobody remembers installing is a common way in, because nobody keeps it updated.
How do I harden the web server itself?
Make sure the web server never hands out files that were not meant to be public, uses HTTPS everywhere, and runs website code with as few permissions as possible. The biggest single quick win is blocking downloads of secrets files such as .env, .git folders, database dumps and zip backups left in the web root.
A checklist for nginx or Apache:
- Block hidden and secrets files. Deny any request for paths that start with a dot (except
/.well-known/, which certificate renewal needs), and keep backups and dumps outside the web root entirely. - HTTPS only. Redirect HTTP to HTTPS and renew certificates automatically. Check renewal works before the certificate expires, not after.
- Do not show server versions in error pages and headers.
- Separate write access. The web server should be able to write only to upload and cache folders, not to the code. Uploaded files should not be able to run as code.
- Keep the application updated. On WordPress, see our WordPress security checklist; for apps your developers build, check the libraries they depend on, which our source code security service does from lock files.
Is there an official hardening standard I can follow?
Yes. The Center for Internet Security publishes CIS Benchmarks, consensus configuration recommendations for many systems, including Ubuntu, Debian, Red Hat Enterprise Linux and others. They are detailed and aimed at technical teams. For a small business server, the checklist above covers the essentials, and a benchmark is a useful next step.
The CIS Benchmarks page lists the Linux distributions covered. Each benchmark runs to hundreds of recommendations, some of which only make sense in larger organisations, so treat it as a reference rather than a to-do list. Applying every item blindly can break applications.
How do I keep a server hardened over time?
Hardening drifts. New software gets installed, someone opens a port for a test and forgets, a new developer is given a password login. A short monthly review and continuous monitoring catch that drift. The NCSC recommends keeping important logs for at least six months, so you can look back if a problem is found late.
The NCSC's logging and monitoring guidance also suggests alerting when logs stop arriving, because silence can mean an attacker has switched logging off. A practical monthly routine:
- Re-run
ss -tulpnand compare with last month's list. - Check
/var/run/reboot-requiredand the date of the last reboot. - Review accounts, sudo group members and every
authorized_keysfile. - Restore one file from backup.
- Check certificate expiry dates and free disk space.
For more on what to watch day to day, see our guide to Linux server monitoring.
How can Cehpoint help keep a server hardened?
Cehpoint's web server security agent checks many of these items continuously. It reports password login and root login settings, open ports (including new ones after a 15-minute learning period), waiting security updates and restart-required, vulnerable system packages, certificates and expiry, new SSH keys, scheduled tasks and programs started from temporary folders.
In Guard mode it also installs waiting security updates, renews expiring certificates, frees disk space at 90% (logs, package cache and unused images, never your files), and blocks addresses that are guessing passwords or attacking the website. It does not change SSH settings for you, because a wrong change can lock you out; it tells you what to change instead. It is part of Cehpoint Agentic SOC, and costs per server are on the pricing page.
Frequently asked questions
How long does it take to harden a Linux server?
For a typical small business web server, a competent administrator can work through the essentials in an afternoon: updates, SSH, firewall, services, web server rules and backups. Testing and scheduling restarts may stretch it over a few days. The monthly review afterwards takes under an hour.
Will hardening break my website?
It can if changes are made without a plan, which is why you take a snapshot first, change one area at a time, and test after each. The riskiest changes are the firewall and SSH, because they can cut off access. Allow SSH in the firewall before enabling it, and keep a second session open when editing SSH settings.
Should I change the SSH port to something other than 22?
Moving SSH to another port reduces log noise from automated scanners, but it is not a security control on its own: scanners find other ports too. Key-only sign-in, no password logins and limiting which addresses can connect matter far more. If you move the port, update your firewall rules first.
Do I need antivirus on a Linux web server?
Classic antivirus matters less on a Linux server than on staff computers. What matters more is spotting the things attackers actually do on servers: unknown programs running from temporary folders, crypto-mining, new SSH keys, new scheduled tasks and new open ports. Monitoring those signs, and acting quickly, covers most real-world attacks on small business servers.
Is my hosting company responsible for hardening my server?
On a rented virtual or dedicated server, usually not. The host keeps the hardware and network running; you, or whoever you pay to manage it, are responsible for the operating system and everything on it. Check your contract. Managed hosting plans sometimes include updates, but rarely cover your website code.
To see what continuous checking would cost for your servers, look at Cehpoint pricing, or read how web server security monitoring works.
Sources checked on 2 December 2026.