So it’s my first time setting up a VPS. Is it to be expected to ban 54 IPs over a 12h timespan? The real question for me is whether this is normal or too much.

$ sudo fail2ban-client status sshd
Status for the jail: sshd
|- Filter
|  |- Currently failed: 3
|  |- Total failed:     586
|  `- Journal matches:  _SYSTEMD_UNIT=ssh.service + _COMM=sshd
`- Actions
   |- Currently banned: 51
   |- Total banned:     54
   `- Banned IP list:   [list of IPs]

fail2ban sshd.conf

$ sudo cat /etc/fail2ban/jail.d/sshd.conf 
[sshd]
enabled = true
mode = aggressive
port = ssh
backend = systemd
maxretry = 3
findtime = 600
bantime = 86400

I have disabled SSH login via password. And only allow it over an SSH key.

$ sudo sshd -T | grep -E -i 'ChallengeResponseAuthentication|PasswordAuthentication|UsePAM|PermitRootLogin'
usepam no
permitrootlogin no
passwordauthentication no
  • pgo_lemmy@feddit.it
    link
    fedilink
    English
    arrow-up
    54
    ·
    12 days ago

    Normal background noise. ssh is a well known protocol/port and scanning is automated.

    • Tanka@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      7
      ·
      12 days ago

      Yeah, I thought so much. But I sort of wanted to be sure. ^^

      • MalReynolds@slrpnk.net
        link
        fedilink
        English
        arrow-up
        9
        ·
        12 days ago

        Pretty much on the low side, but you’ve not been up long. Using key based login you’re fine.

  • BlueBockser@programming.dev
    link
    fedilink
    English
    arrow-up
    20
    ·
    12 days ago

    If you have a public IPv4 address and use port 22, you’ll see lots of login attempts. I wouldn’t worry about it, given that you’ve disabled password login. The only thing I would advise is to disable root login as well (if not done already). Edit: Just saw you’ve already disabled root login.

    If you’d like to reduce the noise somewhat, consider changing to a randomly chosen high port. I’ve done this with my VPS and hardly get any login attempts.

    • Tanka@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      7
      ·
      12 days ago

      Yes, I disabled root login, but the port change is a good idea. Thanks.

      • surewhynotlem@lemmy.world
        link
        fedilink
        English
        arrow-up
        7
        ·
        12 days ago

        I love the concept of port knocking, but it seems like a lot of overhead if the client apps themselves don’t support it.

        Now if the SSH client could take a parameter called knock_on_this port, that would be awesome.

      • BlueBockser@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        12 days ago

        Good luck getting e.g. Ansible to work with that. At that point I’d just switch to a hosting provider with an actual firewall.

        • mumblerfish@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          ·
          12 days ago

          Setup your ssh config to use a proxy command which uses netcat to knock on the ports. Ansible will work with that.

  • pHr34kY@lemmy.world
    link
    fedilink
    English
    arrow-up
    13
    ·
    12 days ago

    They’re portscanning bots.

    I made SSH IPv6-only and it stopped. You can’t scan IPv6 space for open ports.

        • pHr34kY@lemmy.world
          link
          fedilink
          English
          arrow-up
          13
          ·
          11 days ago

          The smallest possible subnet has 18.4 quintillion addresses.

          You can’t scan it before encountering the heat death of the universe.

          Outgoing connections are made on a different address that does not accept incoming connections. You never disclose your real IP when browsing.

          So, no. It can’t be done.

          • Possibly linux@lemmy.zip
            link
            fedilink
            English
            arrow-up
            5
            ·
            10 days ago

            That’s only if you use the brute force method

            IPs are not secret and can be leaked in various ways. Don’t count on IPv6 as a security mechanism as that’s not what it was designed to do

            • pHr34kY@lemmy.world
              link
              fedilink
              English
              arrow-up
              1
              ·
              10 days ago

              It’s literally called “IPv6 privacy extension”. It’s what it does.

              Unless you’re in the middle and fowarding the packets, you won’t stumble across a connectable IPv6 endpoint.

              • Possibly linux@lemmy.zip
                link
                fedilink
                English
                arrow-up
                5
                ·
                10 days ago

                The IPv6 privacy extensions are something else entirely and are not used for anything server side

                You should research IPv6 port scanning techniques. It is harder than IPv4 but still doable depending on the context. If your goal is simply to reduce network traffic due to bots that’s one thing. However, it should not be considered a security mechanism.

  • Possibly linux@lemmy.zip
    link
    fedilink
    English
    arrow-up
    9
    ·
    10 days ago

    I personally wouldn’t waste your time with bans

    Enable public key authentication and disable passwords

  • Phoenixz@lemmy.ca
    link
    fedilink
    English
    arrow-up
    7
    ·
    11 days ago

    That’s very little actually

    Move your SSH port from the standard 22 to one of the higher ones, like 53822

    It’ll remove 99.something% of your attacks as nobody bothers with those ports.

  • clb92@feddit.dk
    link
    fedilink
    English
    arrow-up
    7
    ·
    12 days ago

    Seems likely. Cheap VPSs are often used by beginners, so they’re prime targets for hackers. Known VPS IP-ranges probably get hammered constantly by hackers, who are hoping you set up a service temporarily without enabling any security, or perhaps with a weak temporary password of 1234 or something.

  • Bloefz@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    12 days ago

    That’s not a lot even. I’ve seen much worse. Also with password disabled. Some idiot bots still try to send it whole password lists.

    Just move your SSH to another port, that is enough to get rid of most of the nuisance scans. Or allow SSH only on IPv6. That usually covers it (The IPv6 address space is too big to scan, unless you have a TLD directly pointing to your IPv6)

    What I personally do is run an overlay VPN like tailscale and allow SSH in only via that.

    • irmadlad@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      12 days ago

      What I personally do is run an overlay VPN like tailscale and allow SSH in only via that.

      Same. I use Tailscale as an overlay on the pFsense box and the server itself.

  • bizdelnick@lemmy.ml
    link
    fedilink
    English
    arrow-up
    6
    ·
    12 days ago

    Yes, it is normal.

    # fail2ban-client status sshd
    Status for the jail: sshd
    |- Filter
    |  |- Currently failed: 10
    |  |- Total failed:     4433
    |  `- Journal matches:  _SYSTEMD_UNIT=ssh.service + _COMM=sshd
    `- Actions
       |- Currently banned: 27
       |- Total banned:     668
       `- Banned IP list:   2.57.122.194 45.148.10.183 195.178.110.30 2.57.122.208 92.118.39.195 103.74.123.88 92.118.39.23 2.57.122.196 92.118.39.197 45.148.10.151 92.118.39.236 178.20.210.185 68.178.161.186 80.94.92.183 92.118.39.63 2.57.122.197 2.57.122.191 2.57.122.189 80.94.92.171 94.156.152.18 14.225.7.70 45.78.198.199 211.253.9.160 159.224.213.138 1.214.42.172 103.239.165.114 77.239.111.233
    
  • nonentity@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    5
    ·
    11 days ago

    Rookie numbers.

    My favourite f2b rule is the one strike ban on SSH root login attempts. Any IP originating a SSH root login attempt is clearly compromised, and gets black holed on all my hosts for a month.

    Note: direct SSH login isn’t permitted at all, the daemon is exposed purely to log the attempts.

      • nonentity@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        4
        ·
        11 days ago

        The actual span is a random period between 2 and 4 weeks, it’s interesting to watch how long it takes for attempts to resume.

        I prefer a more granular visibility, repeat offenders automagically ratchet up their stay in the sin bin.

        • Lka1988@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          1
          ·
          11 days ago

          repeat offenders automagically ratchet up their stay in the sin bin.

          Now that is a glorious read first thing in the morning haha

  • irmadlad@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    12 days ago

    Just 54? Those are rookie numbers bro. You need to open up a few more ports. LOL Honestly tho, seems pretty standard. You could change the SSH port which might lower some of the noise but bots now days are pretty sophisticated and it would be trivial to just scan your server and find out which port is SSH. If you want to stop tailing fail2ban nervously on the daily, you could use the hosts.allow/hosts.deny which would lock it down even further. Just remember to set host.allow first then host.deny. You could also deploy any number of secondary security packages like CrowdSec, Wazuh, et al.