A freshly installed Linux server starts out in reasonable shape, but without a few settings its attack surface is needlessly large. This list collects the steps that reduce real risk. It is not meant as a full compliance checklist.
1. SSH: keys instead of passwords
Password-based SSH login is the first attack surface on most servers: an internet-facing port 22 sees login attempts around the clock.
PasswordAuthentication no, key-based authentication onlyPermitRootLogin no, root login disabled- Keys protected with a passphrase, and the private key never stored on the server
If the server faces the internet, put a jump server or VPN in front of it so SSH is not directly exposed.
2. Service minimization
What does not run cannot be attacked. Check what is listening on which ports (ss -tulpn) and stop whatever you do not need. The usual surplus: an old web server, a database that should only be reachable locally, duplicated monitoring agents.
3. Only the ports you need
Run a local firewall on every server, not just at the network edge. Deny by default and allow only the ports actually in use, with source restrictions where possible.
A database should never listen on 0.0.0.0 if only the application server connects to it.
4. Automatic security updates
Installing security patches automatically on servers is debated, but in practice an unpatched system is a bigger risk than the occasional failed update. The compromise: automatic security updates, manual version upgrades.
5. Least privilege
- Services run under dedicated, restricted users instead of root
sudorights granted for specific commands only, never blanket accesssudousage is logged
6. Logging with central collection
After a break-in, the local logs are in the attacker's hands. Copy the system logs to a separate server or a SIEM, because any trace left on the machine can be deleted. We covered this in detail in our article on logging.
The minimum: authentication events, sudo usage, service starts, and package installs.
7. File system integrity
A simple integrity checker (AIDE or similar) flags any change to system binaries or configuration. Run it daily and send the report somewhere else, not to the machine being checked.
8. Mandatory access control
SELinux or AppArmor limits what a process can do, even after it has been compromised. Switching it off is a common reflex during troubleshooting, and afterwards nobody turns it back on. Refining the policy is the better fix.
Containers
If your services run in containers, a few things change:
- Containers should not run as root, and ideally use a read-only root file system
- The host still needs hardening, because a container is not an isolation boundary
- Vulnerability scanning of images should be a standing part of the pipeline, not a one-off
- Do not pass secrets in environment variables, because they show up in the process list
What to measure
- How many services run as root
- How much time passes between the release of a security patch and its installation
- What percentage of logs reaches the central collector
Our IT security services also include building and reviewing server baseline configurations.