Skip to content
Back to Blog
Security8 min read

Server Security Checklist: 12 Steps to Hardening

A practical server security checklist covering patching, access control, and monitoring. Stop guessing what's missing and secure your VPS or dedicated box with these specific steps.

Written by Abdul AbrorTechnical Hosting Support Engineer
Server Security Checklist: 12 Steps to Hardening
On this page

You don't need a pentest report to know if your server is exposed. You need a list. A server security checklist isn't about checking boxes for compliance; it's about closing the gaps that attackers probe first. Most breaches I see in support tickets stem from three things: unpatched software, open ports that shouldn't be open, and weak authentication. This guide walks through the essential layers of defense, from the OS kernel to the application layer. It assumes you have root or sudo access to a Linux-based VPS or dedicated server. If you're running Windows, the concepts apply, but the commands differ. Let's start with the foundation.

Patching: The Boring Part That Saves You

Attackers scan for known vulnerabilities. If you're running a version of Apache, Nginx, or PHP that has a public CVE, you are a target. The first step in any server security checklist is ensuring your OS and packages are current.

Automate Updates

Manual patching is a recipe for disaster. You will forget. Set up unattended upgrades for security patches. On Debian/Ubuntu systems, install the unattended-upgrades package and configure it to apply security updates automatically.

sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades

For RHEL/CentOS/AlmaLinux, use dnf-automatic or yum-cron.

Verify Kernel Updates

Kernel updates often require a reboot. Schedule maintenance windows for reboots. A server running a kernel from two years ago is a liability. Check your current version with uname -r and compare it against your distribution's latest stable release. If you're on a cloud provider, check their metadata service for pending reboots or kernel updates.

Access Control: Locking the Doors

If an attacker gets in, they usually come through SSH or a compromised web application. Tightening access control is the second pillar of your server security checklist.

SSH Hardening

SSH is the most common entry point. Here is what to change in /etc/ssh/sshd_config:

  1. Disable Root Login: Set PermitRootLogin no. Always log in as a regular user and use sudo.
  2. Disable Password Authentication: Set PasswordAuthentication no. Use SSH keys only.
  3. Change the Port: Moving SSH from port 22 to a high port (e.g., 2222) reduces noise from automated scanners. It is not a security measure in itself, but it helps. Update your firewall rules to allow the new port.
  4. Allow Specific Users: Use AllowUsers to restrict which accounts can log in via SSH.

After editing, test your configuration before restarting the service:

sudo sshd -t
sudo systemctl restart sshd

Keep your current terminal session open until you confirm the new settings work. If you lock yourself out, you will need console access via your hosting provider's VNC or IPMI.

Web Application Access

If you run WordPress, Joomla, or a custom PHP app, ensure the web server user (usually www-data or apache) cannot write to sensitive directories. File permissions should be strict. Directories: 755. Files: 644. The wp-config.php file should be 600. Use chown and chmod to enforce this. If you use cPanel, the file permissions are often managed by the system, but you should still verify that the public_html directory isn't writable by the web user.

Network Hardening: The Firewall

A firewall is your first line of defense. If a port is open, it is exposed. You need to decide what traffic is allowed and what is dropped.

UFW or Firewalld

Most modern Linux distributions come with ufw (Ubuntu) or firewalld (RHEL). Enable it. By default, deny all incoming traffic. Then, explicitly allow only what you need.

For a typical web server, you need:

  • Port 80 (HTTP) for redirects to HTTPS.
  • Port 443 (HTTPS) for secure traffic.
  • Your custom SSH port.

Everything else? Drop it.

sudo ufw default deny incoming
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 2222/tcp  # Your custom SSH port
sudo ufw enable

Check Open Ports

Run ss -tulpn or netstat -tulpn to see what is listening. If you see a port open that you don't recognize, investigate it. Is it a database port (3306, 5432)? It should not be exposed to the world. Bind your database to 127.0.0.1 only in its configuration file. If you need remote access to a database, use a VPN or a secure tunnel, not an open port.

Application Layer: Web Server and PHP

The web server and PHP interpreter are where most application-level attacks happen. Harden them.

Nginx/Apache Configuration

Hide server version headers. Attackers use this to identify vulnerable versions. In Nginx, set server_tokens off;. In Apache, set ServerTokens Prod and ServerSignature Off.

Enable security headers. Use a module like headers-more in Nginx to add:

  • X-Content-Type-Options: nosniff
  • X-Frame-Options: SAMEORIGIN
  • Content-Security-Policy: default-src 'self'

These headers mitigate clickjacking and MIME type sniffing attacks.

PHP Hardening

Disable dangerous functions. In php.ini, set disable_functions = exec,passthru,shell_exec,system,proc_open,popen. This prevents PHP code from executing system commands. Also, disable expose_php to hide the PHP version in headers. If you use IonCube or SourceGuardian, ensure the loader is up to date.

Monitoring: Knowing You're Hacked

Prevention is good, but detection is better. You need to know if someone is trying to break in or if they have already succeeded.

Log Monitoring

Enable log rotation and forward logs to a central syslog server or a SIEM. Local logs can be deleted by an attacker. Use logrotate to manage disk space. Monitor /var/log/auth.log for failed SSH attempts. A spike in failed logins indicates a brute-force attack. Set up alerts for this.

File Integrity Monitoring

Use a tool like AIDE or Tripwire to monitor critical system files. If an attacker modifies /etc/passwd or /etc/shadow, you want to know immediately. Configure it to send an email alert on changes.

Intrusion Detection

Consider installing fail2ban. It watches logs and bans IPs that show malicious patterns, like repeated failed SSH logins. It is not a replacement for a firewall, but it adds a layer of dynamic protection.

sudo apt install fail2ban
sudo systemctl enable fail2ban

What to Check First

If you only have time for one thing, check your SSH configuration and firewall rules. These are the two most common points of failure. If you have time for two, add patching. An unpatched server is a ticking time bomb. If you have time for three, set up log monitoring. You cannot fix what you do not know about.

How often should I run this checklist?

Run it monthly. But automate the parts you can. Patching, firewall rules, and log monitoring should be automated. The manual check is for new services you have added and for reviewing access controls. If you add a new database or API, update your firewall and access rules immediately.

Do I need a dedicated security tool?

Not necessarily. Linux has built-in tools that are powerful if configured correctly. ufw, fail2ban, AIDE, and logrotate are free and effective. You only need a dedicated tool if you are managing a large fleet of servers or have complex compliance requirements. For a single VPS or dedicated box, the built-in tools are sufficient.

What if I get locked out?

If you change SSH settings and lock yourself out, use your hosting provider's console access. Most VPS providers offer a web-based VNC or IPMI interface. You can log in there and fix the configuration. Always keep a backup of your sshd_config file before making changes. Store it in a safe place, like a password manager or a separate secure server.

Is a VPN necessary?

A VPN is a good practice for remote access to management interfaces, databases, or internal services. It adds a layer of encryption and hides your IP address. However, it is not a replacement for strong authentication and firewall rules. If you use a VPN, ensure it is properly configured and that the VPN server itself is secure.

Final Thoughts

A server security checklist is not a one-time task. It is a habit. Your server environment changes. New services are added. New vulnerabilities are discovered. Keep your checklist updated. Review it regularly. And if you are unsure about a step, ask for help. Security is not about being perfect; it is about being prepared. Start with the basics. Patch, lock down access, and monitor. That will stop 90% of common attacks. The rest is about staying vigilant and keeping up with the latest threats. Your server is only as secure as its weakest link. Find that link and fix it.