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!

you are viewing a single comment's thread
view the rest of the comments
[–] 34 points 2 days ago* (3 children)

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

  • source
  • hideshow 3 child comments
  • [–] [S] 13 points 2 days 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.

  • source
  • parent
  • [–] 3 points 2 days ago (1 child)

    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.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 2 days 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.

  • source
  • parent