This document lists several tips that you can use to make your cPanel & WHM server more secure.
Exercise caution when you follow these tips. cPanel, L.L.C. takes no responsibility for modifications to individual servers or the security practices of individual servers. Server security requires that the administrator make compromises, which means that any server that allows connections could contain vulnerabilities.
Use secure passwords
Insecure passwords represent the most common security vulnerability. If a hacker compromises an account password, they can use it to deface or infect client sites, or use them to spread viruses.
/etc/login.defs file to configure many password options on your system.
Generally, a secure password utilizes at least eight characters, which includes alphanumeric and grammatical symbols. Never use passwords that include dictionary words or significant dates.
If you move SSH access to a different port, individuals without specific knowledge of your server will not know which port to use for SSH. Many malicious users attempt to use port
22 to access servers. To modify the port on which SSH runs, edit the
We recommend that you use a port number less than
1024 and one that another service does not already use.
- These ports are "privileged" ports, because only the
rootuser can bind to them.
1024and above are "unprivileged" ports, and anyone can use them.
Always use SSHv2 only. SSHv1 will not properly secure connections. You must change the
#Protocol 2,1 line in the
/etc/ssh/sshd_config file to
You may also wish to configure shell resource limits for your users. These limits ensure that applications and scripts cannot use all of your server's resources and take down your server. You can configure shell resource limits in the
/etc/security/limits.conf file on most Linux® systems.
You must secure your Apache installation. The ModSecurity™ tool can help you to secure your server's Apache installation.
- In cPanel & WHM version 11.44 and earlier, you can install ModSecurity in WHM's ModSecurity interface (WHM >> Home >> Plugins >> ModSecurity). For more information, visit the ModSecurity website.
- In cPanel & WHM version 11.46 and later, you can use the following interfaces to manage ModSecurity:
When you compile Apache, include the suEXEC module to ensure that CGI applications and scripts run as the user that owns and executes them. This module identifies the location of malicious scripts and who executed them. It also enforces permission and environment controls.
We strongly recommend that you compile Apache and PHP with the suPHP module. The suPHP module forces all PHP scripts to run as the user who owns the script. This allows you to identify the owner of all PHP scripts that run on your server and find the location of malicious scripts. To compile Apache and PHP with the suPHP module, select the suPHP option in WHM's EasyApache 4 interface (WHM >> Home >> Software >> EasyApache 4) or run the
/scripts/easyapache script from the command line.
Finally, we recommend that you implement symlink race condition protection on your server through EasyApache. For more information about the symlink race condition vulnerability and how to protect against it, read our Symlink Race Condition Protection documentation.
Harden your operating system
We recommend that you take steps to harden your operating system to increase its security. Click the links below to access the security guides of supported Linux distributions on which you can install cPanel & WHM:
- RedHat® Enterprise Linux (RHEL) Security Guide.
- Security and Hardening CentOS 7 Guide.
- CloudLinux Guide to SecureLinks
Harden your /tmp partition
Virtuozzo® and OpenVZ servers do not support this feature.
We recommend that you use a separate
/tmp partition and that you mount it with the
nosuid option. This option forces a process to run with the privileges of the user who executes it. You may also wish to mount the
/tmp directory with
noexec after you install cPanel & WHM.
/usr/local/cpanel/scripts/securetmp script to mount your
/tmp partition to a temporary file for extra security. The temporary file will use 1% of the available disk space in the
/usr partition, from a minimum size of 500MB to a maximum size of 4GB.
If you do not wish for your server to run the
/usr/local/cpanel/scripts/securetmp script, create the
/var/cpanel/disabled/securetmp file. To do this, run the following command:
This file ensures that the script cannot run on your server. However, we strongly recommend that you do not disable the
Restrict your system’s compilers
Most users do not require the use of C and C++ compilers. We strongly recommend that you disable compilers for all users who do not exist in the
compilers group in the
/etc/group file. Many pre-packaged exploits require functional compilers.
- To disable compilers from the WHM interface, use WHM's Compiler Access interface (WHM >> Home >> Security Center >> Compiler Access).
To disable compilers from the command line, run the following command as the
Disable unused services and daemons
Any service or daemon that allows connections to your server may also allow hackers to gain access. To reduce security risks, disable all services and daemons that you do not use.
Disable any services that you do not currently use with WHM's Service Manager interface (WHM >> Home >> Service Configuration >> Service Manager).
Monitor your system
Make certain that you know when a user creates an account. Also make certain that you know what software runs on the server, when software requires updates, and other similar information about your server.
Run the following commands frequently to to ensure that your system functions in the way that you expect:
netstat -anp— Check for programs on ports that you did not install or authorize.
find / \( -type f -o -type d \) -perm /o+w 2>/dev/null | egrep -v '/(proc|sys)' > world_writable.txt— Check the
world_writable.txtfile for all of the world-writable files and directories. This command reveals locations where an attacker can store files on your system.
If you fix permissions on some improperly-written PHP and CGI scripts, the script or website may no longer function.
find / -nouser -o -nogroup >> no_owner.txt— Check the
no_ownerfile for all files that do not have a user or group associated with them. A specific user or group should own all files, to restrict access to them.
ls /var/log/— Many of the different logs on your system can reveal security issues. Check your system logs, Apache logs, mail logs, and other logs frequently to ensure that your system functions as expected.
Third-party software companies offer readily-available utilities to monitor your system and to detect rootkits, backdoors, or other vulnerabilities.
For example, you could install one of the following commonly-available utilities:
- Tripwire – Monitors checksums of files and reports changes.
- chkrookit – Scans for common vulnerabilities.
- Rkhunter – Scans for common vulnerabilities.
- Logwatch – Monitors and reports on daily system activity.
Additionally, we recommend that you allow a technical security professional to perform regular configuration checks of your system.
Control access to services by IP Address
You can use WHM's Host Access Control interface (WHM >> Home >> Security Center >> Host Access Control) to allow only certain IP addresses to access the following services on the server:
- cPanel (
- WHM (
- Webmail (
- Web Disk (
- FTP (
- SSH (
- SMTP (
- POP3 (
- IMAP (
You can also configure the
/etc/hosts.allow file directly via the command line.
Enable a firewall
Before you remove all unused services and daemons or disable unused services and daemons, you can enable a firewall to prevent unwanted access. For more information on the ports that cPanel & WHM requires to function properly, read our How to Configure Your Firewall for cPanel Services documentation.
You may use all of these services or other services, and you should adjust your rules accordingly.
cron job to disable your firewall every five minutes while you test your rules, or your server may lock you out.
We strongly recommend that you run the latest stable versions of the software on your system to ensure that it contains patches for any security issues. Be aware of updates for the following:
- cPanel & WHM*
- User Applications (bulletin boards, content management systems, blog engines, etc)**
- System Software*