How to Block/Unblock IPs from SSH?
In this article, we’ll show you how to Block/Unblock IP Addresses in SSH. You can also Block/Unblock IP Addresses from WHM root for which we have already written an article. But, using SSH to ban/unban IP Addresses is more effective and less time-consuming because you don’t have to browse through the WHM interface in SSH.
Let’s do this.
Block An IP Address from SSH
Well, this can easily be done with a single-line command. Follow the below steps to Block/Unblock IP Addresses.
- First of all, log into your SSH as a root.
- Enter the below command.
Note: Replace the dummy IP Address with the IP Address you want to blacklist.
- If the cphulkd is enabled, the command will execute. Else, you’ll receive the following error.
[root@test ~]# /scripts/cphulkdblacklist 220.127.116.11 cphulkd is not enabled
- If you see the above error, you’ll have to enable cphulkd from the WHM root. Let’s enable it.
Enable cPHulk Protection from WHM
- Log into WHM as a root user.
- Either navigate to the Security Center > cPHulk Brute Force Protection or simply type cPHulk in the search bar and click on the result.
- Hit the Off button to enable cPHulk Brute Force Protection and then switch back to the SSH.
- Once cPHulk is enabled, move back to the SSH and run the previous command again.
- You’ll receive the following result.
[root@test ~]# /scripts/cphulkdblacklist 18.104.22.168 22.214.171.124 has been blacklisted
You’ve successfully blocked an IP Address from SSH.
That’s how you can easily Block/Ban IP Addresses from SSH. Now let’s unblock the IP Address.
Unblock An IP Address from SSH
- Again, log into the SSH as a root user.
- Run the below command and hit enter.
Note: Do not forget to change the dummy IP Address with the IP Address you want to unblock/unban.
- Once you’ll hit the command, you’ll see the below result.
[root@test ~]# /scripts/cphulkdwhitelist 126.96.36.199 188.8.131.52 has been whitelisted
You’ve Successfully unblocked an IP Address using SSH.
Now you know how to Block or Unblock IP Addresses from SSH root. I hope this helps you. If not, you can open a free support ticket from Redserverhost.com. Our experienced Technical Support Team will be happy to assist you.
Also See: Generate SSH Keys in Windows & MacOS
Other than this, you can contact us on Facebook or Twitter for any further inquiries or suggestions.