Linux Server Hardening: A Practical Checklist
A practical checklist for hardening an internet-facing Linux server: updates, SSH, users and sudo, firewall, services, logging and integrity monitoring.

Most Linux servers are not broken into with clever exploits. They are compromised through weak SSH passwords, forgotten services and missing updates. This checklist covers the basics that stop the majority of attacks.
1. Updates
- Install security updates promptly, and turn on automatic security updates (for example
unattended-upgradeson Debian/Ubuntu ordnf-automaticon RHEL-based systems). - Reboot when the kernel is updated, or use live patching where available.
- Remove software you do not use; every package is potential attack surface.
2. SSH
In /etc/ssh/sshd_config:
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
AllowUsers deploy admin
MaxAuthTries 3
- Use SSH keys (Ed25519) protected by a passphrase, or hardware-backed keys.
- Limit SSH to known IP addresses or a VPN where possible.
- Add fail2ban or similar to slow down brute-force attempts.
- Test the new configuration in a second session before closing the first, so you do not lock yourself out.
3. Users and sudo
- One named account per person; no shared logins.
- Grant
sudoonly to those who need it, and review thesudogroup regularly. - Remove or lock accounts of people who have left.
4. Firewall
- Default deny incoming; allow only the ports the server actually serves (for example 443 for a web server, SSH from admin addresses only).
- Use
ufw,firewalldornftables, and check from the outside with a port scan that only the expected ports are open.
5. Services
- List what is listening:
ss -tulpn. - Disable services that are not needed:
systemctl disable --now <service>. - Databases, caches and admin panels (MySQL, Redis, Elasticsearch, Docker API) should never listen on a public interface.
6. Logging and monitoring
- Make sure authentication and system logs are kept (
journaldorrsyslog), and send them to a central place the server cannot erase. - Use
auditdto record sensitive actions such as changes to/etc/passwd,/etc/sudoersand SSH configuration. - Set up alerts for repeated failed logins and new
sudousers.
7. File and kernel settings
- Mount
/tmpwithnoexec,nosuid,nodevwhere your applications allow it. - Check for world-writable files and unexpected SUID binaries.
- Keep SELinux or AppArmor enabled rather than turning them off to “fix” a problem.
8. Backups
- Automated, encrypted backups stored off the server, with at least one copy that cannot be deleted from the server itself.
- Test a restore regularly; an untested backup is a hope, not a plan.
Key takeaways
- Patch automatically, use SSH keys only and block root login.
- Default-deny firewall, and no databases or admin panels on public interfaces.
- Central logs and tested, off-server backups make recovery possible.
This guide was prepared with AI assistance.
Spotted an error or have more information? Contact the editor.