Fail2ban ip banned

  • Hi, I noted something strange lately.


    I have my ssh setup on a different port then 22.


    -Disabled password auth.


    -PKA enabled.


    -Root access disabled.


    I access ssh only locally or via vpn(wireguard container).


    -The IP 185.212.149.206 has just been banned by Fail2Ban after 3 attempts against ssh.

    -The IP 185.204.1.184 has just been banned by Fail2Ban after 3 attempts against ssh.


    What could be happening?


    Thanks

  • You opened up ssh to the internet?


    Are you from Finland and Oy Crea Nova Hosting Solution Ltd is your ISP?

    If you got help in the forum and want to give something back to the project click here (omv) or here (scroll down) (plugins) and write up your solution for others.

  • You opened up ssh to the internet?


    Are you from Finland and Oy Crea Nova Hosting Solution Ltd is your ISP?

    Nope, as said i only connect to my NAS locally or via Wireguard container that's hosted on OMV itself. I'm not in Finland.


    EDIT: Also checked latest handshakes for my Wireguard peers and there is nothing wrong there. So i actually have no clue how/why i'm receiving attempts on my ssh port that's not exposed to the internet :/


    From the Fail2Ban logs i still see attempts now:


    Code
    2022-02-13 15:37:59,242 fail2ban.filter         [19528]: INFO    [ssh] Found 185.204.1.184 - 2022-02-13 15:37:59
    2022-02-13 15:37:59,542 fail2ban.actions        [19528]: WARNING [ssh] 185.204.1.184 already banned
    2022-02-13 15:57:01,552 fail2ban.filter         [19528]: INFO    [ssh] Found 185.204.1.184 - 2022-02-13 15:57:01
    2022-02-13 15:57:01,553 fail2ban.filter         [19528]: INFO    [ssh] Found 185.204.1.184 - 2022-02-13 15:57:01
    2022-02-13 15:57:04,160 fail2ban.filter         [19528]: INFO    [ssh] Found 185.204.1.184 - 2022-02-13 15:57:03
    2022-02-13 15:57:04,462 fail2ban.actions        [19528]: WARNING [ssh] 185.204.1.184 already banned
    2022-02-13 16:10:40,745 fail2ban.filter         [19528]: INFO    [ssh] Found 185.204.1.184 - 2022-02-13 16:10:40
    2022-02-13 16:10:40,746 fail2ban.filter         [19528]: INFO    [ssh] Found 185.204.1.184 - 2022-02-13 16:10:40
    2022-02-13 16:10:42,750 fail2ban.filter         [19528]: INFO    [ssh] Found 185.204.1.184 - 2022-02-13 16:10:42
    2022-02-13 16:10:43,532 fail2ban.actions        [19528]: WARNING [ssh] 185.204.1.184 already banned


    Also found this:

    https://www.abuseipdb.com/check/185.204.1.184

    https://www.abuseipdb.com/check/185.212.149.206


    I can actually ping both the ips i mentioned in my first post.


    I mean, i would expect to find someone trying to force my ssh, but it's not public... how possible? I'm ignoring somehow how fail2ban works?

  • How are you verifying that your sshd is not exposed to the internet?

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • How are you verifying that your sshd is not exposed to the internet?

    Cause i had it in the past. I had the port forwarded to the outside. But now since a long time i have that disabled and only access locally. I also tried to access from outside on the port and it is inaccessible.


    Checked again now, i only have opened ports on my router for SFTP, Wireguard, qBittorrent. The ports forwarded are different from the one i use for ssh ofc.

  • This is detail from the notifications i receive from fail2ban:


    Code
    Lines containing failures of 185.204.1.184
    Feb 13 09:07:51 DK sshd[30610]: User admin from 185.204.1.184 not allowed because none of user's groups are listed in AllowGroups
    Feb 13 09:07:51 DK sshd[30610]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=185.204.1.184  user=admin
    Feb 13 09:07:53 DK sshd[30610]: Failed password for invalid user admin from 185.204.1.184 port 6632 ssh2


    Code
    Lines containing failures of 185.212.149.206
    Feb  7 14:09:14 DK sshd[17407]: User admin from 185.212.149.206 not allowed because none of user's groups are listed in AllowGroups
    Feb  7 14:09:14 DK sshd[17407]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=185.212.149.206  user=admin
    Feb  7 14:09:16 DK sshd[17407]: Failed password for invalid user admin from 185.212.149.206 port 14059 ssh2
  • How can i grab them?

    From where you set them up.


    You might as well have something leaking around vpn or something jumping around the loopback. We can play guessing for a long time.

    Look at the firewall rules to make sure everything is ok and make sure the container routing with vpn is properly filtered.

    And set up your logs and listen for another case.

  • From where you set them up.


    You might as well have something leaking around vpn or something jumping around the loopback. We can play guessing for a long time.

    Look at the firewall rules to make sure everything is ok and make sure the container routing with vpn is properly filtered.

    And set up your logs and listen for another case.

    I think i need some guidance here. I have not touched firewall manually. I just access ssh locally as usual. For the other sevices i mentioned in my previous post i have instead port forwarded the ports on my router.


    Screenshot attached, my firewall tab is empty.

  • What does this command show:


    sudo cat /var/log/auth.log | grep sshd

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • The below indicates a problem with your sshd, likely the initial host key generation did not complete. You should research that error and fix it. But this may or may not be related to your problem. Is there a DSA PRIVATE KEY in that file?


    Feb 13 09:07:51 DK sshd[30610]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key


    The source port number used by the connecting host will be different and is entirely unpredicatble.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • The below indicates a problem with your sshd, likely the initial host key generation did not complete. You should research that error and fix it. But this may or may not be related to your problem. Is there a DSA PRIVATE KEY in that file?


    Feb 13 09:07:51 DK sshd[30610]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key


    The source port number used by the connecting host will be different and is entirely unpredicatble.

    I do not have that file.


    Here is the content:


    steakhutzeee@DK:/etc/ssh$ ll

    total 592

    -rw-r--r-- 1 root root 565189 Jan 31 2020 moduli

    -rw-r--r-- 1 root root 820 Apr 8 2021 omv_sftp_config

    -rw-r--r-- 1 root root 1580 Jan 31 2020 ssh_config

    -rw------- 1 root root 505 Jul 30 2020 ssh_host_ecdsa_key

    -rw-r--r-- 1 root root 176 Jul 30 2020 ssh_host_ecdsa_key.pub

    -rw------- 1 root root 411 Jul 30 2020 ssh_host_ed25519_key

    -rw-r--r-- 1 root root 96 Jul 30 2020 ssh_host_ed25519_key.pub

    -rw------- 1 root root 1823 Jul 30 2020 ssh_host_rsa_key

    -rw-r--r-- 1 root root 396 Jul 30 2020 ssh_host_rsa_key.pub

    -rw-r--r-- 1 root root 754 Jun 18 2021 sshd_config

    -rw-r--r-- 1 root root 3235 Jul 30 2020 sshd_config.ucf-dist

    steakhutzeee@DK:/etc/ssh$


    I actually never used any DSA keys, with Putty i created the key i use to ssh that is an RSA key.


    Can i check the port these ips are trying to login on?

  • Start blocking everything and only allow selected traffic on fw.

    Cut off port access and only allow local IP ... for starters. The problem is bigger because you are exposed in one way or another and you have no control over the box. :/


    netstat -tunlp

    Look what might be listening


    tcpdump host 185.204.1.184

    Look at the network traffic for that specific hostile ip's

  • The use of this key is not up to you. It is automatically generated by the server the first time it starts.


    Google the error message and solve it.


    Unless you change the port sshd runs on it accepts connections to TCP port 22. Telnet to that port and see if you get the banner.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • The use of this key is not up to you. It is automatically generated by the server the first time it starts.


    Google the error message and solve it.


    Unless you change the port sshd runs on it accepts connections to TCP port 22. Telnet to that port and see if you get the banner.

    Uhm but I changed ssh port to another one, and fail2ban is also listening on that port :/


    I have port 22 set nowhere.


    EDIT: Checked with both ssh and telnet on port 22. Connection refused.


    Checking that error now.


    EDIT: Did "sudo dpkg-reconfigure openssh-server" and now i have the missing key generated:


    -rw-r--r-- 1 root root 565189 Jan 31 2020 moduli

    -rw-r--r-- 1 root root 820 Apr 8 2021 omv_sftp_config

    -rw-r--r-- 1 root root 1580 Jan 31 2020 ssh_config

    -rw------- 1 root root 1373 Feb 13 18:17 ssh_host_dsa_key

    -rw-r--r-- 1 root root 597 Feb 13 18:17 ssh_host_dsa_key.pub

    -rw------- 1 root root 505 Jul 30 2020 ssh_host_ecdsa_key

    -rw-r--r-- 1 root root 176 Jul 30 2020 ssh_host_ecdsa_key.pub

    -rw------- 1 root root 411 Jul 30 2020 ssh_host_ed25519_key

    -rw-r--r-- 1 root root 96 Jul 30 2020 ssh_host_ed25519_key.pub

    -rw------- 1 root root 1823 Jul 30 2020 ssh_host_rsa_key

    -rw-r--r-- 1 root root 396 Jul 30 2020 ssh_host_rsa_key.pub

    -rw-r--r-- 1 root root 754 Jun 18 2021 sshd_config

    -rw-r--r-- 1 root root 3248 Feb 13 18:17 sshd_config.ucf-dist


    The error seems to be gone, thank you!


    Anyway i still see login attempts in fail2ban logs :(

  • Is it ok to post the output of netstat here or i should hide something?


    Seems nothing is captured for that host.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!