Unprotected VPS servers face constant scanning from automated attacks targeting default configurations and known vulnerabilities. A compromised server exposes your data, disrupts hosted websites and email services, and can be used to launch attacks on other systems.
You will secure your VPS by hardening SSH access, configuring firewall rules, enabling brute force protection and maintaining regular updates. These steps work across both cPanel and Plesk control panels, creating multiple layers of defence against common attack vectors.
Outdated software contains known vulnerabilities that attackers actively exploit. You need to update your operating system, control panel and server software regularly to close these security gaps.
ssh root@your-server-ip, replacing your-server-ip with your actual server address.dnf update -y
/usr/local/cpanel/scripts/upcp
For Plesk servers, use the Plesk installer command instead:
plesk installer install-all-updates
reboot to restart your VPS.Your system now runs the latest security patches. Schedule regular updates weekly or enable automatic security updates to maintain protection without manual intervention.
Password-based SSH authentication allows unlimited login attempts, making your server vulnerable to brute force attacks. SSH keys provide cryptographic authentication that cannot be guessed or cracked through repeated attempts.
ssh-keygen -t ed25519 -C "your-email@example.com", replacing the email with your actual address. This creates a secure key pair using the Ed25519 algorithm.ssh-copy-id root@your-server-ip to transfer your public key to the server. Enter your current root password when prompted.ssh root@your-server-ip. You should log in without entering your password, using only your key passphrase if you set one.nano /etc/ssh/sshd_config. Find the line containing PasswordAuthentication and change it to PasswordAuthentication no.systemctl restart sshd. This prevents any password-based login attempts while preserving your key-based access.Your SSH service now accepts only cryptographic key authentication. Keep your private key file secure and never share it. Our guide on adding SSH keys to your VPS covers additional configuration options.
Automated attacks scan port 22 constantly because it is SSH’s default port. Moving SSH to a non-standard port reduces automated attack traffic and makes your server harder to find through basic port scans.
nano /etc/ssh/sshd_config and find the line containing #Port 22. Remove the hash symbol and change 22 to your chosen port number./etc/csf/csf.conf and add your new port to the TCP_IN list. For Plesk with Fail2Ban, add the port through the firewall interface.systemctl restart sshd. Do not close your current SSH session until you verify the new port works.ssh -p your-new-port root@your-server-ip, replacing your-new-port with the number you chose. If this works, your SSH port change is complete.SSH now listens on your custom port instead of the default. Remember to specify the port number in all future SSH connections. Our detailed guide on changing your SSH port includes troubleshooting steps if you encounter connection issues.
A properly configured firewall blocks unauthorised access attempts while allowing legitimate traffic to your services. The setup process differs between cPanel and Plesk servers.
ConfigServer Security & Firewall (CSF) provides advanced firewall management with connection tracking, port flood protection and login failure detection. It replaces cPanel’s basic firewall with a more robust security layer.
cd /usr/src
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf followed by sh install.sh. This installs CSF and its web interface plugin for WHM.nano /etc/csf/csf.conf. Change TESTING = "1" to TESTING = "0" to enable CSF in production mode./etc/csf/csf.allow. Add one line containing your IP address, then save the file.csf -r to restart the firewall and systemctl restart lfd to restart the login failure daemon.CSF now monitors your server for suspicious activity and blocks malicious connections. Access the CSF interface through WHM under Plugins to manage firewall rules and view blocked IPs.
Fail2Ban monitors log files for repeated failed login attempts and automatically bans offending IP addresses. Plesk includes Fail2Ban as an optional extension that integrates with the control panel interface.
https://your-server-ip:8443 using your administrator credentials.Fail2Ban now monitors your services and blocks IP addresses that exceed the failed login threshold. Review banned IPs regularly through the Fail2Ban interface to ensure legitimate users are not affected.
Control panel logins face constant brute force attempts where attackers try thousands of password combinations. Built-in protection tools detect these patterns and block attacking IP addresses automatically.
https://your-server-ip:2087 using your root credentials.cPHulk now monitors login attempts across all cPanel services. While CSF provides more advanced features, cPHulk adds an extra layer of protection specifically for control panel access.
Fail2Ban handles brute force protection on Plesk servers. If you completed the Fail2Ban installation in the previous section, brute force protection is already active. Review the Jails section in the Fail2Ban interface to verify protection is enabled for Plesk panel logins.
Two-factor authentication requires a time-based code in addition to your password, preventing unauthorised access even if your password is compromised. Both cPanel and Plesk support 2FA through authenticator apps.
https://your-domain.co.uk:2083.Your cPanel account now requires both your password and a time-based code for login. Each user account needs to configure 2FA separately.
https://your-server-ip:8443.Plesk now requires your authenticator code at every login. Configure 2FA for all administrator and customer accounts to maximise security.
Restricting access to SSH and control panel logins by IP address prevents unauthorised connection attempts from unknown locations. This works best if you connect from a static IP address or a limited range of known addresses.
/etc/csf/csf.allow with nano /etc/csf/csf.allow and add your trusted IP addresses, one per line./etc/csf/csf.conf and find the TCP_IN line. Remove the SSH port from this list, then add it to TCP_IN with your IP restriction in the format port[ip.address].csf -r. Test SSH access from your allowed IP before closing your current session.SSH and control panel access now only accepts connections from your specified IP addresses. Update your whitelist whenever your IP address changes to maintain access.
If you cannot connect via SSH after changing the port or disabling password authentication, you need console access to restore connectivity.
/etc/ssh/sshd_config to restore the previous port or re-enable password authentication temporarily.systemctl restart sshd and test your connection.Overly restrictive firewall rules can block services you need to access. If a service stops working after firewall changes, check the blocked connections log.
/var/log/lfd.log to see recent blocks.Configuration errors prevent security services from starting. Check the service status and logs to identify the problem.
systemctl status csf or systemctl status fail2ban to view error messages.csf -t for CSF or fail2ban-client -t for Fail2Ban.Security extends beyond initial server hardening. Regular monitoring detects intrusions early, while proper backup procedures ensure you can recover from security incidents without data loss.
The CIS Benchmarks provide detailed security configuration guides for Linux servers, covering everything from file permissions to kernel parameters. These industry-standard recommendations help you identify additional hardening opportunities beyond the basics covered here.
Web application firewalls add another security layer by filtering HTTP traffic before it reaches your applications. ModSecurity is an open-source WAF that integrates with Apache and NGINX, protecting against common web attacks like SQL injection and cross-site scripting. Installing ModSecurity with the OWASP Core Rule Set provides immediate protection against known attack patterns.
Automated security scanning identifies vulnerabilities you might miss during manual configuration. Tools like Lynis perform comprehensive security audits, checking for weak passwords, outdated software, insecure permissions and configuration issues. Running regular scans helps you maintain security as your server configuration evolves.
Your VPS now has multiple security layers protecting against common attacks. You configured SSH key authentication, changed default ports, installed firewall protection and enabled brute force detection. These measures significantly reduce your attack surface and block most automated threats.
Review your security logs weekly to identify attack patterns and adjust your firewall rules accordingly. Enable automatic security updates where possible and schedule manual updates for control panel software. Our managed VPS hosting includes proactive security monitoring and regular updates as standard.
Get scalable resources with our VPS hosting with root access and optional software.
Get VPS HostingPerfect for websites and small businesses unlimited bandwidth with cPanel hosting.
Get cPanel Hosting