Deny SSH access by ip address on cpanel

There are many ways available to secure SSH on cPanel Server. We can deny SSH access to all other ip address except from our ISP ips.  In order to allow our ip address and deny all other ips use the following method.

From within your WHM head to Security Center >> Host Access Control.
Here we can add in some rules to control who can access sshd.


Daemon            Access List                              Action                         Comments
sshd                               allow                         working ISPs
sshd              ALL                                      deny                          Deny all other ips

Limit SSH per IP and user
You can limit ssh using /etc/hosts.deny and /etc/hosts.allow. We can use instead of this will deal with the AllowUsers feature in SSH that will limit access per user, and if desired per ip.

To enable this edit /etc/ssh/sshd_config (default location on centos servers, this may be different for you).

At the very bottom you can add

AllowUsers root

This will limit access to only user root. All other login attempts will fail. This will stop the chance of a brute force attach getting into your server as any user but root.

You can also add an IP address

AllowUsers root@ admin@

This above setting will allow user root from user admin from

Restart SSHD service

You must restart SSH for the changes to take place. On centos servers that is /etc/init.d/sshd restart type service sshd restart in console/terminal or go to Restart Services >> SSH Server (OpenSSH).

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

cPHulk Brute Force Protection

WHM/cPanel has a service, protected from Brute Force attack, which is called “cPHulk Brute Force...

Enable SSH key authorized login without root password

You need to generate SSH Key ( the private key )on your cpanel server and then update remote...

How can I Redirect URLs in cPanel

Login your cpanel 1. Click the Redirects button on the front page under the “domains” 2. Enter...

Enable Custom php.ini for Fast CGI

With fast-cgi, custom php.ini needs to be in the cgi-bin folder. 1) Move php.ini to cgi-bin...

ConfigServer Firewall CSF installation

ConfigServer firewall is a popular linux firewall security suite. It is easy to install, flexible...

Powered by WHMCompleteSolution