When you spin up a fresh public Linux instance, automated scanners start knocking on your doors within milliseconds.

It doesn’t take much to get locked down properly, but missing a few basics can leave you exposed.

I’ve put together a straightforward guide covering the essential hardening steps from UFW and SSH key-only auth to secure Docker bindings and automated maintenance.


Original content by The Unknown Universe, written by a human and not AI generated!

  • CallMeAl (like Alan)@piefed.world
    link
    fedilink
    English
    arrow-up
    9
    ·
    1 hour ago

    sudo apt update && sudo apt upgrade -y
    should be
    sudo apt update && sudo apt full-upgrade -y

    also for

    echo “PASTE_YOUR_PUBLIC_KEY_HERE” | ssh your_username@your_server_ip “mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys”

    why not just use ssh-copy-id ?

    edit: added more thoughts

    • UnknownUniverse@lemmy.mlOP
      link
      fedilink
      arrow-up
      5
      ·
      55 minutes ago

      You’re completely right on both counts, full-upgrade handles dependency shifts properly without leaving packages held back, and ssh-copy-id is much cleaner. Updated the guide to reflect both.

  • blueworld@piefed.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    6 minutes ago

    Good guide as a base. Few thought…

    I’d use unattended-upgrades instead of the script. A long know mehod and does similar, and the script doesn’t reboot for a kernel CVE. I’d pair it alongside out-of-band console and an uptime check.

    Fail2ban needs rsyslog enabled (or proper logging) or it silently reads nothing.

    And lastly Journald needs retention set, or you can loose logs in reboots.

    Also I’m not sure if ‘core’ is enough anymore for a public operating and accessed server, but it’s absolutely vital as a start.