Background: 15 years of experience in software and apparently spoiled because it was already set up correctly.

Been practicing doing my own servers, published a test site and 24 hours later, root was compromised.

Rolled back to the backup before I made it public and now I have a security checklist.

  • @[email protected]
    link
    fedilink
    2
    edit-2
    4 months ago

    On a new linux install or image I will always:

    • Make new users(s)
    • Setup new user to sudo
    • Change ssh port
    • Change new user to authenticate ssh via key+password
    • Disable root ssh login
    • @[email protected]
      link
      fedilink
      24 months ago
      • Setup new user to sudo

      I hope it is not a passwordless sudo, it is basically the same as root.

    • @[email protected]
      link
      fedilink
      24 months ago

      That’s more or less the advice I’ve gotten as well. I’ve also read good things about fail2ban which tries to ban sources of repeated authentication failures to prevent brute force password attempts. I’ve used it, but the only person who has managed to get banned is myself! I did get back in after the delay, but I’m happy to know it works.

  • @[email protected]
    link
    fedilink
    English
    764 months ago

    One time, I didn’t realize I had allowed all users to log in via ssh, and I had a user “steam” whose password was just “steam”.

    “Hey, why is this Valheim server running like shit?”

    “Wtf is xrx?”

    “Oh, it looks like it’s mining crypto. Cool. Welp, gotta nuke this whole box now.”

    So anyway, now I use NixOS.

    • @[email protected]
      link
      fedilink
      English
      164 months ago

      Good point about a default deny approach to users and ssh, so random services don’t add insecure logins.

  • @[email protected]
    link
    fedilink
    314 months ago

    As a linux n00b who just recently took the plunge and set up a public site (tho really just for my own / selfhosting),

    Can anyone recommend a good guide or starting place for how to harden the setup? Im running mint on my former gaming rig, site is set up LAMP

  • @[email protected]
    link
    fedilink
    384 months ago

    How are people’s servers getting compromised? I’m no security expert (I’ve never worked in tech at all) and have a public VPS, never been compromised. Mainly just use SSH keys not passwords, I don’t do anything too crazy. Like if you have open SSH on port 22 with root login enabled and your root password is password123 then maybe but I’m surprised I’ve never been pwned if it’s so easy to get got…

    • NSRXN
      link
      fedilink
      144 months ago

      glad my root pass is toor and not something as obvious as password123

    • @[email protected]
      link
      fedilink
      English
      74 months ago

      The one db I saw compromised at a previous employer was an AWS RDS with public Internet access open and default admin username/password. Luckily it was just full of test data, so when we noticed its contents had been replaced with a ransom message we just deleted the instance.

    • @[email protected]
      link
      fedilink
      English
      274 months ago

      By allowing password login and using weak passwords or by reusing passwords that have been involved in a data breach somewhere.

      • @[email protected]
        link
        fedilink
        84 months ago

        That makes sense. It feels a bit mad that the difference between getting pwned super easy vs not is something simple like that. But also reassuring to know, cause I was wondering how I heard about so many hobbyist home labs etc getting compromised when it’d be pretty hard to obtain a reasonably secured private key (ie not uploaded onto the cloud or anything, not stored on an unencrypted drive that other people can easily access, etc). But if it’s just password logins that makes more sense.

  • @[email protected]
    link
    fedilink
    54 months ago

    Good on you learning new skills.

    This is why other sysadmins and cybetsecurity exist. Be nice to them.

    • @[email protected]
      link
      fedilink
      114 months ago

      If it’s public facing, how about dont turn on ssh to the public, open it to select ips or ranges. Use a non standard port, use a cert or even a radius with TOTP like privacyIdea. How about a port knocker to open the non standard port as well. Autoban to lock out source ips.

      That’s just off the top of my head.

      There’s a lot you can do to harden a host.

    • DefederateLemmyMl
      link
      fedilink
      14 months ago

      Do not allow username/password login for ssh

      This is disabled by default for the root user.

      $ man sshd_config
      
      ...
             PermitRootLogin
                     Specifies whether root  can  log  in  using  ssh(1).   The  argument  must  be  yes,  prohibit-password,
                     forced-commands-only, or no.  The default is prohibit-password.
      ...
      
      
    • Fair Fairy
      link
      fedilink
      14 months ago

      Why though? If u have a strong password, it will take eternity to brute force

  • @[email protected]
    link
    fedilink
    34 months ago

    I’ve been quite stupid with this but never really had issues. Ever since I changed the open ssh port from 22 to something else, my server is basically ignored by botnets. These days I obviously also have some other tricks like fail2ban, but it was funny how effective that was.

    • @[email protected]
      link
      fedilink
      04 months ago

      We’re not really supposed to expose the ssh port to the internet at all. Better to hide it behind a vpn.

      But it’s too damn convenient for so many use cases. Fuck it. Fail2Ban works fine.

      You can also set up an ssh tarpit on port 22, which will tie up the bot’s resources and get them stuck in a loop for a while. But I didn’t think it was worth attracting extra attention from the bot admins to satisfy my pettiness.

    • @[email protected]
      link
      fedilink
      14 months ago

      Almost the same here. I also change some ssh settings: disable root login, disable password, allow only public key login. That’s about it. I never had any problems.

  • @[email protected]
    link
    fedilink
    244 months ago

    This sounds like something everyone should go through at least once, to underscore the importance of hardening that can be easily taken for granted

  • @[email protected]
    link
    fedilink
    14 months ago

    I’m having the opposite problem right now. Tightend a VM down so hard that now I can’t get into it.

  • @[email protected]
    link
    fedilink
    204 months ago

    Had this years ago except it was a dumbass contractor where I worked who left a Windows server with FTP services exposed to the Internet and IIRC anonymous FTP enabled, on a Friday.

    When I came in on Monday it had become a repository for warez, malware, and questionable porn. We wiped out rather than trying to recover anything.

  • @[email protected]
    link
    fedilink
    114 months ago

    I’ve always felt that if you’re exposing an SSH or any kind of management port to the internet, you can avoid a lot of issues with a VPN. I’ve always setup a VPN. It prevents having to open up very much at all and then you can open configured web portal ports and the occasional front end protocol where needed.