Disallow All IP for SSH except for French IP

French user

Registered
Jun 17, 2015
4
0
1
France
cPanel Access Level
Root Administrator
Hello,

Is it possible to disallow all IP for SSH / WHM / Cpanel except the French IP's ?
Of course all countries must be allow to be visit the website hosted on my dedicated server...
I checked in Home » Plugins » ConfigServer Security & Firewall and I found only the possibilty to disalow the IP's for all service include the website and not only SSH / WHM / Cpanel
Thanks
 

LostNerd

Well-Known Member
Mar 12, 2014
258
12
18
Hastings, East Sussex, UK
cPanel Access Level
Root Administrator
Twitter
This would be a big task. Having to work out what subnets are exclusive to France and then building allow rules around them rather than trying to block 163 countries instead.

I, personally would rather recommend that you lock it down via a hardware firewall (This is what I do) so that if my IP changes, I can update it in the hardware firewall and then log in to SSH respectively.
 

French user

Registered
Jun 17, 2015
4
0
1
France
cPanel Access Level
Root Administrator
That's not a big task :) if the concept can work with France, the same setting can work with other country and avoid hacking....
I don't have a fix IP internet connection but i'm alway in France, so that's the best solution to reduce the haking
 

LostNerd

Well-Known Member
Mar 12, 2014
258
12
18
Hastings, East Sussex, UK
cPanel Access Level
Root Administrator
Twitter
It simply reduces the chances of hacking to people who are able to use a VPN based in france. Which is still anybody with access to Google (Search free france based VPN).

Can you ask your ISP what IP ranges they use? Even just allowing those ranges is safer than the entire country yet still not ideal.
 

24x7ss

Well-Known Member
Sep 30, 2014
272
17
68
India
cPanel Access Level
Root Administrator
Twitter
Hello :),

Instead of blocking countries, you can access the SSH using public key. As you are having dynamic IP from your ISP, you can setup a public key using which only you can connect through SSH, though your IP gets changes frequently. You can find more details at :
https://documentation.cpanel.net/display/ALD/SSH+Shell+Access
 

French user

Registered
Jun 17, 2015
4
0
1
France
cPanel Access Level
Root Administrator
public key can be a very good idea with SSH but it doesn't solve on WHM and Cpanel ;-)

Concerning => Can you ask your ISP what IP ranges they use?
It's like if I want try to talk with GOD :) the customer services doesn't know what is IP, they only know how to improve their business and they doesn't care with the rest....
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello :)

The feature you are looking for is called "Host Access Control". It's documented at:

WHM - Host Access Control

This is an interface for the /etc/hosts.allow file. You can deny access to all IP addresses for services such as SSH or cPanel/WHM and only allow specific IP addresses or ranges. The key here is that you need to figure out which IP ranges you are connecting from so you know which IP addresses to whitelist. Your ISP might be able to help with this, or you can monitor your own IP address over time to see if the range changes.

Thank you.
 

keat63

Well-Known Member
Nov 20, 2014
1,916
263
113
cPanel Access Level
Root Administrator
I have done exactly this .

I found that my ISP uses only two ranges of IP, so I added both ranges as follows.

192.168.0.0/255.255.0.0
192.169.0.0/255.255.0.0

Obviously ive obfuscated my real range, but you get the picture.

You may need to add a few more as you find them, and you also run the risk of locking yourself out unless you add yourself something which you know is a static IP.
For me, this was my work IP.