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 184.108.40.206 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
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 firstname.lastname@example.org email@example.com
This above setting will allow user root from 220.127.116.11 user admin from 18.104.22.168
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).