Restricting SSH access to 2 or 3 specific IPs

Mangoose

Active Member
Aug 5, 2014
32
0
6
cPanel Access Level
Root Administrator
I am trying to restrict SSH access to two maybe three IP's.

One of the forum analysts suggested this when asked to block one specific IP


Hello :)

You can use a custom "AllowUsers" entry in the /etc/ssh/sshd_config file to limit access to specific IP addresses for specific users. EX:

Code:​
AllowUsers [email protected] cptest1
This above entry would allow root access from IP 1.2.3.4 and the "cptest1" user access from any IP address.

Well my I followed this instruction but I want to add one more IP and make it only possible to logon from two IP's as root and otherwise you must use created "accountuser" like in this example cptest1 which in turn is allowed to logon but not as root but is capable to get su - rights to change to root when logged on.

What is the smartest and securest way to handle this ?
Do I use the command line or the WHM control panel menu;s ?
 

keat63

Well-Known Member
Nov 20, 2014
1,846
222
93
cPanel Access Level
Root Administrator
You can do this easiliy is Host Acess Control.
In the first box type SSHD in the second input your IP and in the third ALLOW.
Add subsequent entries for your IP's then the final entry should be SSHD, ALL, DENY
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,203
363
You can do this easiliy is Host Acess Control.
In the first box type SSHD in the second input your IP and in the third ALLOW.
Add subsequent entries for your IP's then the final entry should be SSHD, ALL, DENY
Hello @keat63,

This will only restrict SSH access to specific IP addresses. The request on this thread relates to restricting SSH access to both usernames and IP addresses.

Thank you.