Why Server Hardening is Non-Negotiable
A shared hosting server might host 200+ client websites. A single security breach can compromise all of them — leading to data loss, reputation damage, and potential legal liability. These 10 hardening steps should be applied to every production server.
1. SSH Key Authentication Only
Disable password-based SSH login entirely:
# /etc/ssh/sshd_config
PasswordAuthentication no
PubkeyAuthentication yes
PermitRootLogin prohibit-password
2. Configure UFW / iptables Firewall
Only open ports that are strictly necessary:
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp # SSH
ufw allow 80/tcp # HTTP
ufw allow 443/tcp # HTTPS
ufw allow 25/tcp # SMTP
ufw allow 587/tcp # Submission
ufw allow 993/tcp # IMAPS
ufw enable
3. Enable Automatic Security Updates
Configure unattended-upgrades to automatically install security patches:
apt install unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades
4. Install and Configure Fail2Ban
Fail2Ban watches log files and bans IPs with suspicious activity. HPanel comes with pre-configured jails for SSH, FTP, and web services.
5. Disable Unnecessary Services
Review running services and disable anything not needed:
systemctl list-unit-files --state=enabled
systemctl disable bluetooth
systemctl disable cups
6. Kernel Hardening (sysctl)
# /etc/sysctl.d/99-hardening.conf
net.ipv4.tcp_syncookies = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
kernel.randomize_va_space = 2
7. Regular Malware Scanning
Use ClamAV (integrated in HPanel) for scheduled scans. Also consider tools like rkhunter for rootkit detection.
8. Secure PHP Configuration
# php.ini hardening
disable_functions = exec,passthru,shell_exec,system,proc_open,popen
expose_php = Off
display_errors = Off
allow_url_fopen = Off
allow_url_include = Off
open_basedir = /home/
9. Implement CSP and Security Headers
Add security headers at the Nginx level for all hosted sites:
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
10. Centralized Log Monitoring
Collect and monitor logs from all services:
- Use
logwatchfor daily email summaries - Forward logs to a central syslog server or ELK stack
- Set up alerts for critical events (failed logins, service restarts)
Conclusion
Server hardening is a continuous process, not a one-time task. HPanel automates many of these steps during installation, but it's crucial to understand what's being protected and why. Apply these 10 tips to every server you manage.