• foggy@lemmy.world
    link
    fedilink
    English
    arrow-up
    47
    ·
    1 year ago

    Setup Fail2ban

    Login only with SSH keys. MFA on SSH login. Use SSH proto 2.

    Disable passwords, x11 forwarding, root logins

    Reduce Idle timeout interval

    Limit users’ SSH access

    That should be more than enough for the average use case.

    • taladar@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      10
      ·
      1 year ago

      Regular updates are definitely necessary too. Also, if you do limit SSH users to a chroot make sure you limit TCP (port) forwarding too.

      • foggy@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Yep. Use SSH keys, not just protocol.

        On connection, it’ll ask for your SSH password (this is different from the users password).

        After that with something like authelia in place, you’ll be asked for a 2fa code.

        • MaggiWuerze@feddit.de
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          1
          ·
          1 year ago

          So, no. SSH can’t do 2FA? I would need to set up Authelia and connect through that? I already use ssh keys instead of passwords to connect to my server

          • lemmyreader@lemmy.ml
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 year ago

            It is possible to have 2FA with a security key and ssh. Been on my to do list for some time to try it.

          • foggy@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 year ago

            Yes it can. I literally have it set up right now.

            When I connect to my vps I am promoted for the password for my SSH key. Only works on a machine that has the ssh key.

            Then I need to use 2fa.

            • MaggiWuerze@feddit.de
              link
              fedilink
              English
              arrow-up
              1
              ·
              1 year ago

              Ah, so it the asks for the TOTP provided by Authelia? I misunderstood, sorry. That’s pretty cool. Do you maybe still have the guide you used to set that up?

  • catloaf@lemm.ee
    link
    fedilink
    English
    arrow-up
    30
    ·
    edit-2
    1 year ago

    Don’t expose anything to the Internet that you don’t absolutely have to. If you can, put everything behind a VPN gateway.

    Make backups. Follow the 3-2-1 rule.

    • ChaoticNeutralCzech@feddit.de
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      That’s why “availability” is a core tenet of security (according to some cybersecurity course I took). It is easy to prevent unauthorized access to data if you have no requirements on authorized access.

  • h3ndrik@feddit.de
    link
    fedilink
    English
    arrow-up
    18
    ·
    edit-2
    1 year ago
    • fail2ban / brute forcing prevention
    • quick, frequent updates(!)
    • containerization / virtualization
    • secure passwords, better keys
    • firewall
    • a hardened operating system (distribution)
    • SELinux / Apparmor / … / OpenBSD
    • not installing unnecessary stuff
    • An admin who is an expert and knows what they do.
    • perishthethought@lemm.ee
      link
      fedilink
      English
      arrow-up
      16
      ·
      1 year ago

      … is an intrusion prevention software framework. Written in the Python programming language, it is designed to prevent brute-force attacks. It is able to run on POSIX systems that have an interface to a packet-control system or firewall installed locally, such as iptables or TCP Wrapper.

  • Possibly linux@lemmy.zip
    link
    fedilink
    English
    arrow-up
    7
    ·
    1 year ago

    Check out online resources such as the Nist cyber stuff.

    Basic things include disabling unnecessary services, disabling password authentication, setting up and verifying the firewall, configuring selinux and so on.

  • lemmyreader@lemmy.ml
    link
    fedilink
    English
    arrow-up
    7
    arrow-down
    1
    ·
    1 year ago

    Ask yourself a few questions first before following the massive amount of suggestions and then locking yourself out and so on.

    • What are you worried about ?
    • How important is your stuff ?
    • Make backups and check them

    Still worried ? Then there’s the easy way out : Hire some security auditor to help you find holes you left.

  • dallen@programming.dev
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    I like to require access to 22 via IP whitelist and all services on SSL behind a reverse proxy. Doesn’t leave much surface to attack.

    • Phoenixz@lemmy.ca
      link
      fedilink
      English
      arrow-up
      4
      ·
      1 year ago

      Also, move ssh to a different, higher port. Since ssh isn’t exactly for noobs, changing the port is easy enough to work with and that alone already reduces port scans and what not

      • Nik282000@lemmy.ca
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        I recently setup Guacamole (Web based VNC/RDP/SSH) with totp and was able to close external SSH access. Now everything I run can sit behind a single reverse proxy, no extra ports.

  • Pyrosis@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    Firewall and deciding on an entry point for system administration is a big consideration.

    Generating a strong unique password helps immensely. A password manager can help with this.

    If this is hosting services reducing open ports with something like Nginx Proxy Manager or equivalent. Tailscale and equivalent(wire guard, wireguard-easy, headscale, net bird, and net maker) are also options.

    Getting https right. It’s not such a big deal if all the services are internal. However, it’s not hard to create an internal certificate authority and create certs for services.

    If you have server on a VPS. Firewall is again your primary defense. However, if you expose something like ssh fail2ban can help ban ips that make repeated attempts to login to your system. This isn’t some drop in replacement for proper ssh configuration. You should be using key login and secure your ssh configuration away from password logins.

    It also helps if you are using something like a proxy for services to setup a filter list. NPM for example allows you to outright deny connection attempts from specific IP ranges. Or just deny everything and allow specific public IPs.

    Also, if you are using something like proxmox. Remember to configure your services for least privileges. Basically the idea being just giving a service what it needs to operate and no more. This can encompass service user/group names for file access ect.

    All these steps add up to pretty good security if you constantly assess.

    Even basic steps in here like turning on the firewall and only opening ports your services need help immensely.

    • Possibly linux@lemmy.zip
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      The biggest thing is to change the defaults and to limit access. Unless your are the target of a nation state the attacks against your network will be automated.

  • LordOfTheChia@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    Do a search for you server OS + STIG

    Then, for each service you’re hosting on that server, do a search for:

    Service/Program name + STIG/Benchmark

    There’s tons of work already done by the vendors in conjunction with the DoD (and CIS) to create lists of potential vulnerable settings that can be corrected before deploying the server.

    Along with this, you can usually find scripts and/or Ansible playbooks that will do most of the hardening for you. Though it’s a good Idea to understand what you do and do not need done.

  • ___@lemm.eeBanned from community
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Run SCAP tool with a STIG baseline.