I just setup a minecraft server on an old laptop, but to make it acessible i needed to open up a port. Currently, these are the ufw rules i have. when my friends want to connect, i will have them find their public ip and ill whilelist only them. is this secure enough? thanks

`Status: active

To Action From


22/tcp ALLOW Anywhere Anywhere ALLOW my.pcs.local.ip`

also, minecraft is installed under a separate user, without root privlege

  • ShortN0te@lemmy.ml
    link
    fedilink
    English
    arrow-up
    8
    ·
    2 months ago

    A port is not secure or insecure. The thing that can lead to security risks is the service that answers that port.

    Use strong authentication and encryption on those services and keep them up to date.

  • ricecake@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 months ago

    I would use something like wireguard, or another VPN service you can host yourself if your router supports it natively.

    From the looks of it Minecraft servers seem to have dogshit authentication, so using some form of private network setup is going to be your best move.

  • helpimnotdrowning@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    2 months ago

    as long you are only forwarding Minecraft’s 25565 port from your router to your server machine, it should be fine. Just make sure to keep Online mode on, use the whitelist, and get your plugins from trusted sources. Otherwise I wouldn’t worry too much.

    I see others recommending VPN solutions like zerotier for your friends to connect to; I don’t personally feel like this is necessary, and (in my experience), making your friends do more technical setup than just connecting to the server is often a big turn-off.

    Bonus: If you ever take a peek at your server logs while it’s running (and exposed to the Internet, if you avoid said VPN solutions), you might notice a lot of weird connections from IPs and usernames you don’t recognize. These are server scanners and threat scanners that look for vulnerable servers to connect to and exploit. This is normal and you’ll be fine as long as you keep that whitelist and stay up-to-date on developments in the server admin space.

  • WhyJiffie@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    2 months ago

    if I were you, I would do IP whitelisting at the firewall instead of or besides the Minecraft server

    • helpimnotdrowning@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 months ago

      This might also become a hassle since basically all residential connections (likely of OPs friends) have dynamic IPs - if someone wants to join while OP is away, but their IP has changed since their last connection, now they have to wait on OP to update the firewall rules.

      Apart from getting your MSA token stolen, there’s not really much that can get around server login (yet). All online-mode logins pass through Microsoft (part of the reason why Xbox service outages seem to affect Minecraft so much).

      If your friends all individually seem to stay within some certain IP ranges (ex, first handful digits always stay the same, 12.34.56.xx), then I’d say go ahead with whitelisting them fully (ex, 12.34.56.xx --> 12.34.56.0/24, CIDR notation). If they jump around unpredictability, I would stick with the username-based whitelisting and online-mode-only.

      • WhyJiffie@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 month ago

        maybe a wireguard network is the way to go then, of course without being configured as the default destination for everything. there IPs are always fixed, but at that point you don’t even need a firewall

  • Decronym@lemmy.decronym.xyzB
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    2 months ago

    Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:

    Fewer Letters More Letters
    DNS Domain Name Service/System
    IP Internet Protocol
    SSH Secure Shell for remote terminal access
    SSO Single Sign-On
    TCP Transmission Control Protocol, most often over IP
    VPN Virtual Private Network
    VPS Virtual Private Server (opposed to shared hosting)

    7 acronyms in this thread; the most compressed thread commented on today has 11 acronyms.

    [Thread #959 for this sub, first seen 8th Sep 2024, 20:35] [FAQ] [Full list] [Contact] [Source code]

  • slazer2au@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    assuming they are not behind a CGN whitelisting your mates place should be OK. But I would also move SSH away from a well known port. In the event something happens to the whitelist, crawlers will not jump on you straight away.

      • ShortN0te@lemmy.ml
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 months ago

        no. The default port is fine. Changing the default port does nothing for security. It only stops some basic crawler, when you are scared by crawler, then you should not host anything on the internet.

        • fahfahfahfah@lemmy.billiam.net
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 months ago

          The volume on 22 will be a lot higher than a non default port. With 22 open my router was basically getting DDOS’d at times

          • ShortN0te@lemmy.ml
            link
            fedilink
            English
            arrow-up
            1
            ·
            2 months ago

            Then using something like fail2ban to block bad acting connections is far more effective and you even get a security benefit out of it.

            Also, when a few scripts try to connect via ssh DDOS your router then something is messed up. Either a shitty router from 20 years ago or you have a Bandwidth lower than 100kbps.

  • mark3748@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    Why is port 22 open? Is this on your router as well or just the server?

    This is SSH, which you should pretty much never have open (to the internet! Local is fine) MC is by default 25565. You will have every bot on the internet probing that port.

      • Manifish_Destiny@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 months ago

        Your ssh rule says it’s from anywhere. You want to change port 22 to 25565, and run /op username on your Minecraft server to whitelist your friends. Make sure your whitelist flag is turned on with your server config.

        Instead of allowing traffic over your port from anywhere, you can specify your friend’s external IP.

        • Manifish_Destiny@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 months ago

          You can test it out by running ‘telnet <ip> <port>’ to check if the port is open. This is best done from another network.

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

        Normal for who? I wouldn’t expose SSH on 22 to the internet unless you have someone whose full time job is monitoring it for security and keeping it up to date. There are a whole lotta downsides and virtually no upsides given that more secure alternatives have almost zero overhead.

        • i_am_not_a_robot@discuss.tchncs.de
          link
          fedilink
          English
          arrow-up
          0
          ·
          2 months ago

          Shodan reports that 35,780,216 hosts have SSH exposed to the internet.

          Moving SSH to ports other than 22 is not security. The bots trying port 22 on random addresses with random passwords don’t have a chance of getting in unless you’re using password authentication with weak passwords or your SSH is very old.

          SSH security updates are very infrequent and it takes practically no effort to keep SSH up to date. If you’re using a stable distribution, just enable automatic security updates.

          • lud@lemm.ee
            link
            fedilink
            English
            arrow-up
            2
            ·
            2 months ago

            Moving to another port isn’t a bad idea though. It gives you cleaner logs which is nice.

      • IphtashuFitz@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 months ago

        If you have ssh open to the world then it’s better to disable root logins entirely and also disable passwords, relying on ssh keys instead.

      • Trainguyrom@reddthat.com
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 months ago

        For public facing only use key based authentication. Passwords have too much risk associated for public facing ssh

      • strawberry@kbin.earthOP
        link
        fedilink
        arrow-up
        0
        ·
        2 months ago

        yeah no I should have considered that. didn’t lick the most secure password. will change when I get home

        • 2xsaiko@discuss.tchncs.de
          link
          fedilink
          English
          arrow-up
          2
          ·
          2 months ago

          Don’t use passwords for public SSH in the first place. Disable password authentication and use pubkeys.

          • catloaf@lemm.ee
            link
            fedilink
            English
            arrow-up
            2
            arrow-down
            1
            ·
            2 months ago

            And disable ssh to root. Hell, just disable root login altogether and use sudo.

  • Swarfega@lemm.ee
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    More effort than I would consider. I’d just allow all traffic incoming on that port. I’d only consider whitelist if someone was giving me grief. Even then that would be after blacklisting an IP wasn’t solving my problem.

    • IphtashuFitz@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 months ago

      Port 22 is the default SSH port and it receives a TON of malicious traffic any time it’s open to the whole internet. 20 years ago I saw a newly installed server with a weak root password get infected by an IP address in China less than an hour after being connected to the open internet.

      With all the bots out there these days it would probably take a lot less time if we ran the same experiment again.

      • Swarfega@lemm.ee
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 months ago

        Ha. That’s my bad. I didn’t even read the firewall rules listing 22/SSH. I agree on not opening 22 to the world. It just invites bots throwing passwords at it.

        I just read Minecraft in the original post which from reading runs from 25565 which I wouldn’t worry about. If OP needs 22 for admission I’d either whitelist it or use a VPN/Tailscale.

        • Zangoose@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          2 months ago

          25565 also gets a decent amount of malicious traffic because of Minecraft though. I’d recommend switching the port to something different at the very least. When I hosted a server for the first time on 25565 my router pretty immediately gave me warnings about attempted network traffic coming from Europe/Asia when I (and everyone I gave the IP to) live in the US.

  • StrawberryPigtails@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    The simplest way to do this, is to put the server on a private vpn (I use Tailscale, there are others) and expose ports only to the vpn. Then you share access to the vpn with your friends.

    With Tailscale, this is as simple as sending them a share link for the host. They will need to have an account at Tailscale, and have the client running, but they will then be able to access the host with a static ip address.

    As a general rule of thumb, nothing should be exposed to the public internet unless you want that service to be public access and then you need to keep it up to date. If a vulnerability doesn’t currently exist for the service, one will sooner rather than later. SSH, especially password only ssh, can be broken into fairly easily. If you must expose ssh to the public internet for whatever reason, you need to be using IP white lists, password protected keys, change the default port, and turn off service advertisements and ping responses. I’m probably missing something. When someone scans your server randomly, they should see nothing. And if they fail login they should be ip blocked.

  • Lettuce eat lettuce@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    IP white lists and firewall exceptions will help, but exposing ports on your home router is almost always a bad idea, especially for something as trivial as a game server.

    I would highly recommend Tailscale. It’s free for up to 3 users, and if you have more friends than that, I would have them all sign up with free accounts and then share your laptop device with their tailnets.

    It’s very easy to setup and use, costs nothing, and will be far more secure than opening ports and trying to set up IP white lists, protocol limitations, etc.

    Tailscale creates something called an “overlay network” it’s basically a virtual LAN that exists on top of your real network and can be extended to other people and devices over the internet. It’s fully encrypted, fast, and like I said, very easy to set up.

  • catloaf@lemm.ee
    link
    fedilink
    English
    arrow-up
    0
    arrow-down
    1
    ·
    edit-2
    2 months ago

    More or less. The biggest issue is if your or their IP address changes, it’ll stop working.

    I don’t know what Minecraft’s track record is on security, but I assume it’s not great. Ideally, you’d also put public facing services in a DMZ, so that if they do get compromised, they can’t reach anything else.