Home / Guides

Server guide

AlmaLinux security hardening checklist for small business servers

This guide is for VPS, dedicated and cPanel admins using AlmaLinux. It provides a practical checklist to assess, secure, and maintain a hardened system.

7 min readUpdated November 2026 by the RootManage teamWorks on Ubuntu, Debian, AlmaLinux and Rocky unless noted

The short answer

Hardening AlmaLinux involves verifying system defaults, applying security configurations, and establishing ongoing monitoring. Follow the checklist to reduce attack surface and keep the server compliant with best‑practice standards.

Why AlmaLinux hardening matters

Securing a fresh AlmaLinux installation reduces the attack surface by limiting unnecessary services and ensuring that only the latest, patched packages are running. A hardened system is less likely to be compromised by automated exploits that target default configurations. For small businesses and hosting teams, this translates into fewer incidents, lower downtime, and a stronger position when demonstrating compliance with industry standards such as PCI‑DSS or HIPAA, which require secure operating environments.

Implementing hardening measures also improves audit readiness. Log files are correctly configured, user privileges are restricted, and network exposure is minimized. These practices make it easier to prove that the system meets security controls during external assessments. Even a modest hardening effort can reduce the likelihood of data breaches, protecting customer data and maintaining trust in the brand.

Baseline security assessment

Baseline security assessment is the first step before hardening a server. Start by gathering a snapshot of the current configuration. Use uname -a to verify the kernel, cat /etc/os-release to confirm the distribution and version, and rpm -qa or dpkg -l to list installed packages. These commands give a clear picture of what is running and help identify obsolete or vulnerable packages that may need updating or removal. Maintaining an inventory of software versions is essential for tracking security patches and compliance requirements.

Next, examine network exposure. Run ss -tunlp to list listening sockets and the processes that own them. Check iptables -L -n or firewalld-cmd --list-all to review active firewall rules. A quick netstat -tulpn can also surface open ports. By documenting these findings, you establish a baseline that will allow you to measure the impact of any hardening changes and quickly spot regressions or new vulnerabilities.

  • Check for unnecessary services running on the server
  • Verify that only required ports are open
  • Ensure firewall rules are restrictive
  • Confirm that package lists are up to date
terminal
# Example commands – read before running
# View kernel and distribution info
uname -a
cat /etc/os-release
# List installed packages
rpm -qa | sort
# Show listening sockets
ss -tunlp

Look for services that are not needed for the application, such as FTP or Telnet. Open ports should match the application’s requirements only. Firewall rules should block all inbound traffic except the necessary ports. Any discrepancies should be investigated and addressed before proceeding with hardening steps.

Core hardening steps

Updating packages is the first step in hardening a VPS or cPanel server. Run the package manager’s update command to pull the latest security patches and bug fixes. On AlmaLinux, use sudo dnf update -y and review the output for any packages that require a reboot. Keeping the kernel and core utilities current reduces the attack surface and ensures compatibility with newer security features. Once the system is up to date, configure the firewall to allow only required traffic. Enable and start firewalld with sudo systemctl enable --now firewalld. Use sudo firewall-cmd --permanent --add-service=http and sudo firewall-cmd --permanent --add-service=https to permit web traffic, then reload with sudo firewall-cmd --reload. Disable any unused services with sudo systemctl disable --now <service>, and verify the status with systemctl list-unit-files | grep disabled.

  • Enable SELinux in enforcing mode with sudo setenforce 1. Check status with sestatus. Configure firewall zones for isolated services. Disable root SSH login via password.
terminal
# Example commands – review before running
sudo dnf update -y
sudo systemctl enable --now firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo setenforce 1

After applying these steps, confirm that the firewall only allows HTTP/HTTPS traffic, SELinux is enforcing, and no unnecessary services are running. Check firewall-cmd --list-all and systemctl list-unit-files | grep enabled for verification.

Secure SSH and remote access

Use SSH key‑based authentication instead of passwords. Generate a key pair on a trusted workstation with ssh-keygen, copy the public key to the server using ssh-copy-id or by appending it to ~/.ssh/authorized_keys. Set PasswordAuthentication no and PubkeyAuthentication yes in /etc/ssh/sshd_config. Restrict the file permissions of the .ssh directory and its contents to prevent unauthorized reads. After editing, reload the service and verify that password logins are rejected while key logins succeed.

Change the default SSH listening port to a non‑standard value such as 2222. Edit /etc/ssh/sshd_config and set Port 2222, then restart the daemon. To limit brute‑force attempts, install fail2ban and enable the [sshd] jail, which will ban IPs after a configurable number of failed logins. Also consider disabling root login with PermitRootLogin no and allowing only specific users via AllowUsers. These steps reduce exposure and add throttling without affecting legitimate access.

  • Generate and distribute SSH keys; never rely on password logins.
  • Set a custom SSH port and update firewall rules accordingly.
  • Disable root SSH login and permit only required accounts.
  • Enable fail2ban or a similar tool to block repeated failed attempts.
terminal
# Example commands (review before execution)
ssh-keygen -t ed25519 -C "admin@example.com"
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server.example.com
sudo sed -i 's/^#Port 22/Port 2222/' /etc/ssh/sshd_config
sudo systemctl restart sshd
sudo yum install -y fail2ban
sudo systemctl enable --now fail2ban

After applying these changes, test SSH access using the new port and key pair from a trusted client. Verify that password prompts are disabled and that repeated failed attempts trigger a temporary ban as shown in the fail2ban log.

Application and service hardening

Web servers on AlmaLinux should run only the necessary modules and listen on the minimal set of ports. Disable the default Apache or Nginx modules that are not needed, such as mod_php if PHP is served via FastCGI. For PHP, set cgi.fix_pathinfo=0 in php.ini and use php-fpm with a dedicated pool that has a limited user and no write permissions to the web root. Database services like MariaDB or MySQL should bind to 127.0.0.1 only, and the root account should be removed or disabled for remote access. Use strong, unique passwords and enable SSL/TLS for all remote connections. cPanel services must be kept up to date; disable unused plugins and restrict the WHM interface to specific IP ranges using the cPanel IP Access Control feature.

  • - Disable unused Apache modules (e.g., mod_php).
  • - Bind MariaDB to localhost only.
  • - Use php-fpm pools with limited user rights.
  • - Enable SSL/TLS for all remote connections.
  • - Restrict WHM access to trusted IPs.
terminal
# Disable an unused Apache module
sudo a2dismod php8.3
# Bind MariaDB to localhost only
sudo sed -i 's/^bind-address.*/bind-address = 127.0.0.1/' /etc/my.cnf
# Restart MariaDB to apply changes
sudo systemctl restart mariadb

Verify that Apache no longer loads the disabled module, MariaDB listens only on 127.0.0.1, and the WHM interface is inaccessible from untrusted IPs.

What to avoid when hardening

When hardening a VPS or dedicated server, avoid blanket disabling of core security mechanisms such as SELinux or AppArmor. These modules enforce mandatory access controls that protect critical files and services. Turning them off removes a layer of defense and can expose the system to privilege escalation attacks. Instead, configure them to permissive mode for troubleshooting, then revert to enforcing after adjustments.

Another common mistake is enabling weak cryptographic ciphers or protocols. Allowing SSLv2, SSLv3, or early TLS versions opens the server to downgrade attacks. Likewise, opening every port on the firewall gives attackers a larger attack surface. Keep only the ports required for your services and enforce strong cipher suites in your web and mail server configurations.

Maintaining a hardened state

Regular patching is the first line of defense. Use the distribution’s package manager to keep all packages up‑to‑date. On AlmaLinux, run dnf update daily or schedule a cron job that checks for updates and notifies the admin. Keep the kernel, system libraries, and web server packages current to close known vulnerabilities before attackers can exploit them. A disciplined update schedule reduces the attack surface and ensures that security patches are applied before they are widely known.

Log monitoring and automated compliance checks keep the system in a hardened state over time. Configure rsyslog or journald to forward logs to a central collector, and use tools like auditd to audit privileged commands. Set up a lightweight compliance scanner such as lynis or OpenSCAP to run nightly and report deviations from baseline hardening rules. Automating these checks allows you to detect misconfigurations early and maintain a secure posture without manual intervention.

  • Use a dedicated log aggregation service for central visibility
  • Schedule nightly compliance scans with lynis
  • Alert on critical log events via email or SMS
terminal
# Example: run a nightly Lynis scan and email the report
0 2 * * * /usr/bin/lynis audit system | mail -s "Lynis Report" admin@example.com

After running the scan, verify that the report contains no critical or high‑severity findings. If any are present, review the affected files or services and remediate before the next scheduled run.

If you would rather have engineers do this for you, see Linux server management, Windows server management or emergency malware cleanup.

Questions people ask

How often should I run the AlmaLinux hardening checklist?

The hardening checklist should be run whenever a new server is provisioned, after major system updates, or when a security incident is suspected. A quarterly review is a good practice for ongoing compliance.

Can I apply these hardening steps on a running production server?

Yes, most hardening steps can be applied to a live production server, but always take a snapshot or backup first. Apply changes during a maintenance window and monitor the system closely afterward.

What tools can help automate security checks on AlmaLinux?

Tools such as `auditd`, `lynis`, `osquery`, and `OpenSCAP` can scan AlmaLinux for configuration drift and missing hardening steps. These tools provide reports that help track compliance over time.

How do I verify that SELinux is enforcing after configuration?

Check SELinux status with `sestatus`. The output line “SELinux status: enabled” and “Current mode: enforcing” confirm that SELinux is active and enforcing policies.

Want a person to look at it?

Tell us what you see. We reply with what we think is wrong and what it would take to fix it.