this post was submitted on 10 Feb 2025
816 points (99.4% liked)

linuxmemes

22440 readers
1452 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
  • Don't get baited into back-and-forth insults. We are not animals.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
  • 5. πŸ‡¬πŸ‡§ Language/язык/Sprache
  • This is primarily an English-speaking community. πŸ‡¬πŸ‡§πŸ‡¦πŸ‡ΊπŸ‡ΊπŸ‡Έ
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
  • Β 

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.

    founded 2 years ago
    MODERATORS
     

    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.

    (page 4) 22 comments
    sorted by: hot top controversial new old
    [–] [email protected] 15 points 3 days ago (3 children)

    Although disabling the root user is a good part of security, leaving it enabled should not alone cause you to get compromised. If it did, you were either running a very old version of OpenSSH with a known flaw, or, your chosen root password was very simple.

    load more comments (3 replies)
    [–] [email protected] 173 points 3 days ago (7 children)

    Basic setup for me is scripted on a new system. In regards to ssh, I make sure:

    • Root account is disabled, sudo only
    • ssh only by keys
    • sshd blocks all users but a few, via AllowUsers
    • All 'default usernames' are removed, like ec2-user or ubuntu for AWS ec2 systems
    • The default ssh port moved if ssh has to be exposed to the Internet. No, this doesn't make it "more secure" but damn, it reduces the script denials in my system logs, fight me.
    • Services are only allowed connections by an allow list of IPs or subnets. Internal, when possible.

    My systems are not "unhackable" but not low-hanging fruit, either. I assume everything I have out there can be hacked by someone SUPER determined, and have a vector of protection to mitigate backwash in case they gain full access.

    load more comments (7 replies)
    [–] [email protected] 26 points 3 days ago* (last edited 3 days ago) (2 children)

    You should turn off ssh password logins on external facing servers at a minimum. Only use ssh keys, install fail2ban, disable ssh root logins, and make sure you have a firewall limiting ports to ssh and https.

    This will catch most scripted login attempts.

    If you want something more advanced, look into https://en.m.wikipedia.org/wiki/Security_Technical_Implementation_Guide and try to find an ansible playbook to apply them.

    [–] [email protected] 7 points 3 days ago (3 children)

    Just turn off password logins from anything but console. For all users. No matter where it runs.

    It becomes second to nature pretty fast, but you should have a system for storing / rotating keys.

    load more comments (3 replies)
    load more comments (1 replies)
    [–] [email protected] 23 points 3 days ago* (last edited 3 days ago) (2 children)

    And this is why every time a developer asks me for shell access to any of the deployment servers, I flat out deny the request.

    Good on you for learning from your mistakes, but a perfect example for why I only let sysadmins into the systems.

    [–] [email protected] 3 points 3 days ago* (last edited 3 days ago)

    We have it at my company its just a very small group and we have to manually enable it for production and its through tools like teleport. Staging and the like its free game there for them for debugging, same infra through. Gives us best of all worlds

    [–] [email protected] 11 points 3 days ago (2 children)

    You're not wrong! Devops made me lazy

    load more comments (2 replies)
    [–] [email protected] 51 points 3 days ago (1 children)

    Interesting. Do you know how it got compromised?

    [–] [email protected] 72 points 3 days ago* (last edited 3 days ago) (14 children)

    I published it to the internet and the next day, I couldn't ssh into the server anymore with my user account and something was off.

    Tried root + password, also failed.

    Immediately facepalmed because the password was the generic 8 characters and there was no fail2ban to stop guessing.

    [–] [email protected] 11 points 3 days ago* (last edited 3 days ago) (1 children)

    because the password was the generic 8 characters and there was no fail2ban to stop guessing

    Oof yea that'll do it, your usually fine as long as you hardened enough to at least ward off the script kiddies. The people with actual real skill tend to go after...juicer targets lmao

    load more comments (1 replies)
    [–] [email protected] 95 points 3 days ago (1 children)

    Don't use passwords for ssh. Use keys and disable password authentication.

    [–] [email protected] 53 points 3 days ago* (last edited 3 days ago) (12 children)

    More importantly, don't open up SSH to public access. Use a VPN connection to the server. This is really easy to do with Netbird, Tailscale, etc. You should only ever be able to connect to SSH privately, never over the public net.

    load more comments (12 replies)
    [–] [email protected] 7 points 3 days ago (2 children)

    Which distro allows root to login via SSH?

    load more comments (2 replies)
    [–] [email protected] 29 points 3 days ago (3 children)

    wow crazy that this was the default setup. It should really force you to either disable root or set a proper password (or warn you)

    [–] [email protected] 8 points 3 days ago (1 children)

    Love Hetzner. You just give them your public key and they boot you into a rescue system from which you can install what you want how you want.

    [–] [email protected] 10 points 3 days ago (1 children)

    I think their auction servers are a hidden gem. I mean the prices used to be better. Now they have some kind of systrem that resets them when they get too low. But the prices are still pretty good I think. But a year or two ago I got a pretty good deal on two decently spec'd servers.

    People are scared off by the fact you just get their rescue prompt on auctions boxes... Except their rescue prompt has a guided imaging setup tool to install pretty much every popular distro with configurable raid options etc.

    [–] [email protected] 7 points 3 days ago (1 children)

    Yeah, I basically jump from auction system to auction system every other year or so and either get a cheaper or more powerful server or both.

    [–] [email protected] 6 points 3 days ago

    I monitor for good deals. Because there's no contract it's easy to add one, move stuff over at your leisure and kill the old one off. It's the better way to do it for semi serious stuff.

    [–] [email protected] 12 points 3 days ago (11 children)

    Most distributions disable root by default

    load more comments (11 replies)
    [–] [email protected] 2 points 3 days ago

    Now that you mentioned it, it didn't! I recall even docker Linux setups would yell at me.

    [–] [email protected] 7 points 3 days ago

    Ah, timeless classic.

    [–] [email protected] 4 points 3 days ago

    Any idea what ip addresses were used to compromise it?

    load more comments (8 replies)
    load more comments
    view more: β€Ή prev next β€Ί