I find the idea of self-hosting to be really appealing, but at the same time I find it to be incredibly scary. This is not because I lack the technical expertise, but because I have gotten the impression that everyone on the Internet would immediately try to hack into it to make it join their bot net. As a result, I would have to be constantly vigilant against this, yet one of the numerous assailants would only have to succeed once. Dealing with this constant threat seems like it would be frightening enough as a full-time job, but this would only be a hobby project for me.

How do the self-hosters on Lemmy avoid becoming one with the botnet?

  • golden_zealot@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    57 minutes ago

    If you don’t need stuff publicly accessible, and just need it accessible to you, then set up a small computer on the network as an ssh Bastion host/jump server, put it on a VPN connection with a VPN provider that offers dyndns, forward the ssh port through the dyndns, and then off network, reverse proxy in with socks5 via key based ssh -D to gain access to all the services available inside the LAN.

    Been doing this for a few years, works great and no one is getting in without my ssh key.

  • teawrecks@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 hours ago

    Step 1 is to do everything inside your network with data you don’t care about. Get comfortable starting services, visiting them locally, and playing around with them. See what you like and don’t like. Feel free to completely nuke everything and start from scratch a few times. (Containers like Docker make this super easy).

    Step 2 is to start relying on it for things inside your network. Have a NAS, maybe home assistant, or some other services like Immich or Navidrome. Figure out how to give services access to your data without relying on them to not harm it (use read only mounts, permissions, snapshots, etc.)

    Step 3 is to figure out how to make services more accessible away from home. Whether that is via a VPN, or something like tailscale, or just carefully opening specific ports to specific secure and up-to-date services. This is the part you’re feeling anxious about, and I think you’ll feel less anxious if you do steps 1 and 2 first and not even think about 3 yet. Consider it its own challenge, and just do one challenge at a time.

  • Sanctus@anarchist.nexus
    link
    fedilink
    English
    arrow-up
    2
    ·
    6 hours ago

    Well for one its not as automatic as it sounds. Basic protections will get you far. I have a minecraft server exposed but it only accepts connections from 3 specific places. Remember its the same as ever other real life deterrant, make yourself less of a target than the next guy. It also really helps not having juicy company data on your network. Home networks are way less of a target because you dont have any fine booty to loot.

  • Atemu@lemmy.ml
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    3
    ·
    9 hours ago

    Yikes, lot’s of bad advice in this thread.

    My advice: Go develop an actual threat model and find and implement mitigations to the threats you’ve identified.

    If you can’t do that, that’s totally okay; it’s a skill that takes a lot of time and effort to learn and is well-compensated in the industry.

    You will need to pay for it. Either through an individual assessment by someone who knows what they’re doing, managed hosting services where the hoster is contractually liable and has implemented such measures, by risking becoming part of a botnet or by not hosting in a world-public manner.

    My recommendations:

    • Pay for proper managed hosting for every part of your system that you are not capable of securing yourself. This is a general rule that even experienced people follow by i.e. renting a VPS rather than exposing their own physical HW. There are multiple grades to this such as SaaS, PaaS and IaaS.
    • Research, evalue and implement low-hanging fruit measures that massively reduce the attack surface. One such measure would be to not host in a manner that is accessible to the entire world and instead pay for managed authenticated access that is limited to select people (i.e. VPN such as Tailscale)
    • git gud
    • Atemu@lemmy.ml
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      2
      ·
      9 hours ago

      Wow is that ever a load of snake oil.

      I see this kind of guide as actively harmful because it creates a false sense of security.

      • lefaucet@slrpnk.net
        link
        fedilink
        English
        arrow-up
        3
        ·
        7 hours ago

        Is there bad advise on there?

        I skimmed it and there’s lots of good advice I think.

        I’m no security expert and this is an honest question.

  • glizzyguzzler@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    21
    arrow-down
    1
    ·
    edit-2
    6 hours ago

    The only thing that can get hacked is something that responds on the World Wide Web.

    So you limit the scope of what talks to the WWW:

    Wireguard VPN will not respond unless the magic keys are correct, it’s ideal security and obscurity. Put everything you can behind it.

    For things I want on the WWW without a VPN, I split out two options otherwise.

    1. Caddy checking mTLS certificates that basically allows a device access without extra steps - relying on Caddy to be strong and mTLS to be strong.

    2. Authentik’s proxy check, I think Authelia has this too, but to access a site you hit an Authentik login first.

    For both of those, you rely on those services not having 0-day hacks. More likely for these services to stay ahead of the game and/or fix quick than something that doesn’t exist just to do authentication. I run them in containers that are run by independent users and are read-only with capabilities limited, in a VM.

    I’d say the Caddy route is more secure than Authentik, but it needs more effort to setup the certificate stuff. Authentik route needs a web browser to log in with. Obviously the WG VPN is primo.

    Edit: also tailscale is just managed wireguard, so it has the same benefits as a wireguard vpn with the catch a company has access to your network also now. But really simplifies setup……

  • WxFisch@lemmy.world
    link
    fedilink
    English
    arrow-up
    39
    ·
    1 day ago

    Only expose services internally then use a secure VPN to access your services, this makes your network no more vulnerable in practice than not self hosting. If you need/want to expose something to the internet, make sure you setup your network right. Use a DMZ to separate that service and leverage something like CrowdSec along with good passwords, antivirus, and keep things patched.

    • a1studmuffin@aussie.zone
      link
      fedilink
      English
      arrow-up
      10
      ·
      1 day ago

      Thanks for the CrowdSec tip, I’ve already got an nginx reverse proxy set up but wasn’t aware I could integrate this for extra protection.

    • BingBong@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      4
      ·
      1 day ago

      How do I check this? I route everything on my internal network only. But how should I make sure its not accessible remotely? I cannot just have these on an air gapped network.

      • WxFisch@lemmy.world
        link
        fedilink
        English
        arrow-up
        8
        ·
        1 day ago

        You can run a port scan against your public IP from another network to see what is open. But if you haven’t specifically set something up for external access through port forwarding you are probably fine.

    • corvus@lemmy.ml
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 day ago

      Should I do the same if I want to expose an OpenAI compatible API to access an LLM to chat remotely on local technical documents?

      • WxFisch@lemmy.world
        link
        fedilink
        English
        arrow-up
        6
        ·
        1 day ago

        It doesn’t usually matter what the service is, the basic concepts are the same. If you want to access a service you host on your internal network from another external network you either need to use a VPN to securely connect into your network, or expose the service directly. If you are exposing it directly you should put it (or a proxy like NPM) in your DMZ. The specifics of how to do this though will vary from service to service and with your specific network config.

  • RIotingPacifist@lemmy.world
    link
    fedilink
    English
    arrow-up
    15
    ·
    21 hours ago

    Outbound firewall and SMAC protections.

    If you compromise my server you’ll struggle to phone home without manual intervention, which is good enough to stop botnets.

    • irmadlad@lemmy.world
      link
      fedilink
      English
      arrow-up
      7
      ·
      21 hours ago

      pFsense + IDS/IPS segmenting network and a robust set of rules would pretty much get you there.

  • ShortN0te@lemmy.ml
    link
    fedilink
    English
    arrow-up
    30
    ·
    1 day ago

    The ‘immediate attacks’ ppl mention is just static background noise. Server / scripts that run trying to find misconfigured, highly out to date or exploitable endpoints/servers/software.

    Once you update your software, set up basic brute force protection and maybe regional blocking, you do not have to worry about this kind of attack.

    Much more scary are so called 0-Day attacks.

    1. No one will waste an expensive exploit on you
    2. It sometimes can happen that 0-Days that get public get widly exploited and take long time to get closed like for example log4shell was. Here is work necessary to inform yourself and disable things accorsing to what is patched and what not.

    As i already said, no one will waste time on you, there are so much easier targets out there that do not follow those basic rules or actually valuable targets.

    There is obviously more that you can do, like hiding everything behind a VPN or advanced thread detections. Also choosing the kind of software you want to run is relevant.

      • ShortN0te@lemmy.ml
        link
        fedilink
        English
        arrow-up
        2
        ·
        9 hours ago

        The other answer is already good but I answer more general.

        Rate limiting. Do not allow as many requests as your CPU can handle but limit authentication requests. Like a couple requests per second already goes a long way.

      • cecilkorik@lemmy.ca
        link
        fedilink
        English
        arrow-up
        10
        ·
        23 hours ago

        fail2ban mainly, but also things like scaling login delays (some sort of option often built into the software you’re running, but just as often not configured by default), or if you’re feeling particularly paranoid account locking after too many failures, and in general just not using default, predictable, common usernames or weak passwords, and honestly it’s even helped a bit by having slow hardware and throttled network bandwidth.

        The goal is to make it so that someone can’t run a script that sends 100 million login attempts per second for common or stolen usernames and passwords and your server just helpfully tries them all and obediently tells them none of those worked… until one of them does.

        Not only does this encourage them to TRY sending 100 million login attempts per second because your server isn’t refusing it, which is a huge waste of bandwidth and resources, it also makes it really likely that they’re eventually going to guess one right.

  • neidu3@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    24
    ·
    24 hours ago

    It’s mostly automated exploit finders looking for low hanging fruit. fail2ban and up to date software is your friend.

    • k4j8@lemmy.world
      link
      fedilink
      English
      arrow-up
      5
      ·
      17 hours ago

      There’s a lot of technical answers here, but Tailscale is what you want OP. Self-hosting is only a risk if you open ports. Tailscale doesn’t require opening any ports.

      Alternatively, you could set up your own VPN and forward one port to the VPN. The risk of port forwarding to VPN such as Wireguard or OpenVPN is minimal.

      The risk of being attacked applies to those that port forward web traffic so it can be accessed without a VPN by themselves or others. If you don’t do that, the risk is very low.

    • bridgeenjoyer@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      ·
      23 hours ago

      Is it bad to forward ports temporarily to game with friends? And deactivate after?

      I dont have the energy to learn new fanglad networking since everything is so insecure now…im used to 2009 servers.

      • Stez@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        2
        ·
        14 hours ago

        It’s not really complicated at all you just download the tailscale app make an account and then hit share to your friends. That’s how I run a Minecraft server for me and my friends because I was too lazy to figure out how to port forward. It was easier to just sudo apt install tailscale and essentially be done.

      • planish@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        4
        ·
        23 hours ago

        No?

        I mean, how else are you meant to play the game actually?

        I guess you could be like opening ports just to particular IPs. And you need a game that isn’t Swiss cheese that gets immediately hacked.

        But like hackers don’t sort of seep in through port forwards; they need to physically identify and exploit a particular vulnerability.

  • tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    9
    ·
    22 hours ago

    Have a limited attack surface will reduce exposure.

    If, say, the only thing that you’re exposing is, oh, say, a Wireguard VPN, then unless there’s a misconfiguration or remotely-exploitable bug in Wireguard, then you’re fine regarding random people running exploit scanners.

    I’m not too worried about stuff like (vanilla) Apache, OpenSSH, Wireguard, stuff like that, the “big” stuff that have a lot of eyes on them. I’d be a lot more dubious about niche stuff that some guy just threw together.

    To put perspective on this, you gotta remember that most software that people run isn’t run in a sandbox. It can phone home. Games on Steam. If your Web browser has bugs, it’s got a lot of sites that might attack it. Plugins for that Web browser. Some guy’s open-source project. That’s a potential vector too. Sure, some random script kiddy running an exploit scanner is a potential risk, but my bet is that if you look at the actual number of compromises via that route, it’s probably rather lower than plain old malware.

    It’s good to be aware of what you’re doing when you expose the Internet to something, but also to keep perspective. A lot of people out there run services exposed to the Internet every day; they need to do so to make things work.