The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Restricting SSH access to 2 or 3 specific IPs

Discussion in 'Security' started by Mangoose, Feb 17, 2017.

Tags:
  1. Mangoose

    Mangoose Active Member

    Joined:
    Aug 5, 2014
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    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 root@1.2.3.4 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 ?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,204
    Likes Received:
    1,297
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  3. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    875
    Likes Received:
    25
    Trophy Points:
    28
    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
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,204
    Likes Received:
    1,297
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
Loading...

Share This Page