Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 17
  1. #1
    Member
    Join Date
    Dec 2003
    Location
    Maryland
    Posts
    98

    Default Serious Problem - My SSH is being hacked

    I've been noticing in the last couple weeks, that my SSH server is being hammered by numerous IP's trying to get passwords for root, and even try accounts that don't exist like admin, guest, test, etc.

    Is there a way to prevent logins to ssh from all other IP's except a given range I designate?

    I'm on dsl, however as you know, it's static to a point. However I know what my DSL company's IP range is, and would like to restrict logins to just that range.

    Or is there an easier way than just blocking the IP's? Because that's what I've been doing.

    Thanks in advance,
    Chew
    Last edited by Chew; 08-05-2004 at 05:36 AM.

  2. #2
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    It's a very common attack at the moment. You should be able to restrict access to SSH through /etc/hosts.deny and hosts.allow:
    man hosts.deny

    Or, if you have APF, you could simply only allow access to port 22 from your IP address or range using the /etc/apf/allow_hosts.rules and deny_hosts.rules
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  3. #3
    Member
    Join Date
    Dec 2003
    Location
    Maryland
    Posts
    98

    Default

    ahh I didn't think about using apf for restrictions.

    Thanks again Chirpy!
    Chew

  4. #4
    Member
    Join Date
    Dec 2003
    Location
    Maryland
    Posts
    98

    Default

    one other thing.

    Say my IP is 64.155.58.12
    I want to always allow 64.55.x.x to connect.

    Would I enter the following?
    tcp:in:d=22:s=64.155.0.0/16 ?

    What's the correct format for the entry?

    Thanks,
    Chew

  5. #5
    Member bamasbest's Avatar
    Join Date
    Jan 2004
    Posts
    531

    Default

    Don't forget...

    If you have APF installed, you should install Brute Force Protection (BFD) from the same vendor. This script will automatically update/deny the IP's of the kiddies running the hack attempts.

  6. #6
    Member
    Join Date
    Jun 2004
    Posts
    111

    Unhappy

    I have the exact same problem - happening loads over the last few weeks - I don't have APF, just a plain old miniserver at memset.. what can I do to stop it?

    Any ideas gratefully received.


    Regards,
    Dean

  7. #7
    Member
    Join Date
    Jun 2004
    Location
    Columbus, OH
    Posts
    113

    Default

    If you can't use firewall rules to block out connections, you can block on username also. Add this line to your sshd_config.

    AllowUsers user1,user2

    Only add users you want to connect.

    Thanks
    -Seth

  8. #8
    BANNED
    Join Date
    Feb 2002
    Posts
    656

    Default

    Quote Originally Posted by chirpy
    Or, if you have APF, you could simply only allow access to port 22 from your IP address or range using the /etc/apf/allow_hosts.rules and deny_hosts.rules
    How do you do this in APF? What is the syntax? Does it only restict it user root or all users?

  9. #9
    Member
    Join Date
    Jun 2004
    Location
    Columbus, OH
    Posts
    113

    Default

    Quote Originally Posted by AbeFroman
    How do you do this in APF? What is the syntax? Does it only restict it user root or all users?
    You don't filter on user name in APF, just on bits. edit your sshd_config to filter based on username.

    Thanks
    -Seth

  10. #10
    Member
    Join Date
    Aug 2002
    Location
    Huntington Beach, Ca
    Posts
    232

    Default

    I was getting hit for about 2 weeks and then I simply changed the SSH port and closed 22 with APF and all went quiet.

  11. #11
    BANNED
    Join Date
    Feb 2002
    Posts
    656

    Default

    How do you close a port with APF?

  12. #12
    BANNED
    Join Date
    Feb 2002
    Posts
    656

    Default

    Quote Originally Posted by sjackson909
    You don't filter on user name in APF, just on bits.
    -Seth
    What do you mean but "just on bits"?

  13. #13
    Member
    Join Date
    Oct 2001
    Posts
    97

    Default

    Quote Originally Posted by sjackson909

    AllowUsers user1,user2

    Only add users you want to connect.
    Let's say you allow "user1" but not root. If you login as "user1" will SSH still allow you to SU to root (assuming "user1" is in the wheel group)?

  14. #14
    Member
    Join Date
    Jun 2004
    Location
    Columbus, OH
    Posts
    113

    Default

    Quote Originally Posted by SonServers
    Let's say you allow "user1" but not root. If you login as "user1" will SSH still allow you to SU to root (assuming "user1" is in the wheel group)?
    yep, ssh is just the tranport to get you to the shell. AbeFroman, I know not one thing about APF.. I use ipfw on FreeBSD. No linux for me.

    Thanks
    -Seth

  15. #15
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    TBH, I find it simpler to move SSH to a different port (just modify /etc/ssh/sshd_config and restart sshd). It won't stop port range scanners, but it will bounce the skiddie scripts like the one currently doing the rounds.
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

Similar Threads & Tags
Similar threads

  1. SSH problem
    By nidhin_nl in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 06-20-2006, 11:36 PM
  2. Bandmin hacked? Do you have this problem too?
    By Saeven in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 04-11-2006, 11:04 PM
  3. BIG PROBLEM !!! hacked by spammer ??
    By Ham in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 11-29-2005, 07:06 AM
  4. ssh problem
    By tomtom2002 in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 03-29-2004, 03:10 AM
  5. SSH problem
    By kris1351 in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 01-09-2004, 01:04 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube