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
    20
    ·
    7 hours 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
      11
      ·
      7 hours 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
      2
      ·
      6 hours ago

      I love ssh-copy-id, but end up doing it manually about half the time anyway. I’ve tried integrating it into build scripts and find what the op did more reliable.

      Could just be me though… it is Linux, and there a dozen ways to skin Linus. We all have our assholes and opinions.

      • CallMeAl (like Alan)@piefed.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        6 hours ago

        I’ve tried integrating it into build scripts In a script I would also write out all the commands I want to run. After all, ssh-copy-id is a shell script itself. For instructions for someone to run interactively, I think ssh-copy-id makes the most sense.