Skip to main content
We are aware of an issue after updating to cPanel versions 11.110.0.65, 11.126.0.21, or 11.128.0.11, some cPanel plugins or features are no longer functioning properly including WP Toolkit. Please see the following article for more information and updates:
Update to latest cPanel 110, 126, or 128 versions removes "addonfeatures" directory.

Allow only certain countries's IP to access root

Comments

9 comments

  • iserversupport
    You can do that using WHM using Security Center >> Host Access Control. There you can deny ssh for all IP except one.
    0
  • crliuh
    [quote="iserversupport, post: 1683102">You can do that using WHM using Security Center >> Host Access Control. There you can deny ssh for all IP except one.
    Thanks iserversupport. by any chance it can unblock just from the specified country's IP?
    0
  • triantech
    [quote="crliuh, post: 1683221"> by any chance it can unblock just from the specified country's IP?
    crliuh, You can use csf ( default firewall ) to block the IPs from specified countries. In the csf configuration file "/etc/csf/csf.conf" there is an option to block access from an IP range by using country code. CC_DENY = "" Specify the country codes over there ^ Use this link to find the allocations of IPs to countries and their codes.
    0
  • triantech
    [quote="crliuh, post: 1683221"> by any chance it can unblock just from the specified country's IP?
    crliuh, You can use csf ( default firewall ) to block the IPs from specified countries. In the csf configuration file "/etc/csf/csf.conf" there is an option to block access from an IP range by using country code. CC_DENY = "" Specify the country codes over there ^ You can find the respective country codes and IPs using a quick google search. Thankx
    0
  • quizknows
    Keep in mind blocking or allowing entire countries with CSF creates a very large amount of iptables rules and may affect performance. I simply recommend changing your SSH port to a non-default port number. This stops the majority of random bruteforce scans on SSH. Alternately, you could close the SSH port in the firewall config and only whitelist the IP that you are working from. If you did this with CSF, you could always log in to WHM to whitelist a new IP through the configserver panel. Also, disable cphulk, it's not good for much other than locking you out of your own server.
    0
  • crliuh
    [quote="triantech, post: 1683242">crliuh, You can use csf ( default firewall ) to block the IPs from specified countries. In the csf configuration file "/etc/csf/csf.conf" there is an option to block access from an IP range by using country code. CC_DENY = "" Specify the country codes over there ^ You can find the respective country codes and IPs using a quick google search. Thankx
    thanks triantech, another concern arised by AMquizknows, large amount of ip tables rules may affect performance. :confused: [COLOR="silver">- - - Updated - - - [quote="quizknows, post: 1683352">Keep in mind blocking or allowing entire countries with CSF creates a very large amount of iptables rules and may affect performance. I simply recommend changing your SSH port to a non-default port number. This stops the majority of random bruteforce scans on SSH. Alternately, you could close the SSH port in the firewall config and only whitelist the IP that you are working from. If you did this with CSF, you could always log in to WHM to whitelist a new IP through the configserver panel. Also, disable cphulk, it's not good for much other than locking you out of your own server.
    because my ips are dynamic that's y i need to fixed the ip within the country range. the best option would be only authentic base from computers. if disabled cphulk there will be more login failed attempt. i don't think that's good for my server right?
    0
  • triantech
    crliuh, A quick whois on the IPs which are attacking shows that they are from China. So i think instead of allowing country lists, try to block the IP's from China ( if you do not have any valid requests coming from there ). And yes, if the CC allow and CC deny list is filled with lotta countries, performance might get affected. Also, as quizknows suggested why not change the default SSH port and in addition, disable direct root login and create a su user.
    0
  • quizknows
    [quote="crliuh, post: 1683462">if disabled cphulk there will be more login failed attempt. i don't think that's good for my server right?
    cPhulk doesn't block IPs, it only blocks targeted accounts, which is why it's basically worthless. Use CSF/LFD; it will block the attacking IP addresses without locking you out. If you have CSF, then cphulk is unnecessary; the most it's going to do is stop you from logging in during an attack. Changing your SSH port, and as traintech suggested, a su user with direct root login disabled, is a more reasonable and efficient solution than blocking or allowing entire countries worth of IP addresses.
    0
  • georgeb
    [quote="crliuh, post: 1682972"> question is, how can i allow only my computer to access SSH root? please advise. thanks.
    Just add this line in your file /etc/ssh/sshd_config : AllowUsers root@you_rip_address_here
    After this only your IP address can access server via ssh (with root user) Regards
    0

Please sign in to leave a comment.