Security
Brute attack and /var/log/btmp
**/var/log/btmp` is a system security log that records all failed login attempts to your Linux server.**/var/log/btmp- It is a binary file: You cannot read it using normal text commands like
cat,nano, orless. If you try, your screen will fill with unreadable scrambled code. - Strict Permissions: Because it logs failed login details (which sometimes accidentally contain real passwords typed into the username field), only the
rootuser can read it.
last with the -f flag. Run this command with sudo:sudo last -f /var/log/btmp
root ssh:notty 192.168.1.50 Thu Aug 27 17:45 - 17:45 (00:00)
admin ssh:notty 45.142.120.14 Thu Aug 27 17:42 - 17:42 (00:00)
invalid ssh:notty 185.220.101.5 Thu Aug 27 17:40 - 17:40 (00:00)
- Column 1: The username attempted (e.g.,
root,admin, or completely fake usernames likeinvalid). - Column 3: The IP address of the machine or bot trying to break into your server.
/var/log/btmp to swell to hundreds of megabytes or gigabytes very quickly.sudo last -f /var/log/btmp | wc -l
2010, sophisticated automated bots will eventually scan your server, find the open port, and begin brute-forcing it./var/log/btmp file and find out exactly who is attacking you and if Fail2ban is doing its job.btmp file using this command:sudo last -f /var/log/btmp | awk '{print $3}' | sort | uniq -c | sort -nr | head -n 10
- What this does: It extracts the IP column, counts the duplicate entries, and displays the top 10 most aggressive IP addresses alongside the exact number of failed attempts they made.
sudo last -f /var/log/btmp | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 10
- What to look for: You will likely see
root,admin,user, orubuntu. If you see actual personal usernames that exist on your system, it means the attack is more targeted.
2010 means you need to ensure Fail2ban is actually listening to that custom port. Otherwise, it will ignore the attacks.sudo fail2ban-client status sshd
- Look at the "Banned IP list" at the bottom of the output. If it shows active IP addresses, Fail2ban is successfully protecting your new port.
- If the list is completely empty despite having thousands of entries in your
btmplog, Fail2ban might still be looking for port 22.
/etc/fail2ban/jail.local):[sshd]
enabled = true
port = 2010
logpath = %(sshd_log)s
backend = %(sshd_backend)s
port = 2010 is explicitly set. If you make changes, restart the service:sudo systemctl restart fail2ban
103.137.184.170 alone has hammered your custom SSH port over 216,000 times.Journal matches: _SYSTEMD_UNIT=sshd.service), has banned 427 IPs total, and currently has 7 IPs blocked—including 211.253.8.115, which is number 10 on your top attackers list.sudo nano /etc/fail2ban/jail.local
[sshd] section and adjust these parameters:[sshd]
enabled = true
port = 2010
maxretry = 3 ; Ban them after just 3 failed attempts
findtime = 1d ; Look for 3 failures within a 24-hour window
bantime = 1w ; Ban them for a full week (or use -1 for permanent)
Ctrl+O, Enter, Ctrl+X) and restart Fail2ban:sudo systemctl restart fail2ban
103.137.184.170 has broken the threshold completely. You can force Fail2ban to ban it instantly without waiting for the next trigger:sudo fail2ban-client set sshd banip 103.137.184.170
root user. If you haven't already, completely disable logging directly into the root account via SSH.sudo nano /etc/ssh/sshd_config
PermitRootLogin and change it to no:PermitRootLogin no
sudo systemctl restart ssh
meson user password or SSH key working before doing this, so you don't lock yourself out)./var/log/btmpsudo truncate -s 0 /var/log/btmp
- Do you log in using a password or an SSH Cryptographic Key? (Switching to keys stops brute forces completely).
- Would you like help configuring UFW (the firewall) to restrict SSH port 2010 access to only your specific home/office IP?
#PermitRootLogin prohibit-password is commented out, the system defaults to allowing root login attempts under certain conditions. Since you are using SSH keys for your user account, you should explicitly deny the root user from ever logging in.sudo nano /etc/ssh/sshd_config
# symbol in front of it):PermitRootLogin no
Ctrl+O, Enter, Ctrl+X) and restart SSH:sudo systemctl restart ssh
103.137.184.170, you should block it permanently at the firewall level so it cannot access your Nextcloud instance or any other port:sudo ufw insert 1 deny from 103.137.184.170 to any
insert 1 ensures this rule sits at the very top of your firewall checklist, blocking the packet instantly).sudo ufw delete allow 2010/tcp
sudo ufw allow from YOUR_HOME_IP to any port 2010 proto tcp
YOUR_HOME_IP with your actual public IP address, which you can find by searching "what is my IP" on your computer).Security against Brute attack
This volume of failed logins is normal background noise for any server with port 22 open to the internet — automated bots scan all IPv4 addresses and start hammering common usernames within minutes of your server going online. Your fail2ban and UFW are doing exactly what they're supposed to: stopping them from actually getting in.
That said, you can eliminate most of this traffic entirely. If you only have SSH keys enabled, the thousands of password guesses are harmless and simply never succeed.
Is this normal?
-
1564 failed logins / 192 bans / 7329 firewall blocks is a typical-to-calm level for a public server. Many freshly-unprotected boxes see tens of thousands of attempts daily.
-
The important test: do any of the failed logins succeed? If they don't (key-based auth only), this is nuisance traffic, not a breach.
-
One thing worth checking: if most failures come from a single IP, fail2ban may be misconfigured or its filter may not match your auth log format — otherwise it should be banning that IP. Verify with
sudo fail2ban-client status sshd.
What you can do to cut it down
The single most effective change is to make password login impossible, so the brute-force attempts can never succeed:
-
Use SSH keys only — this alone eliminates the overwhelming majority of brute-force risk.
-
Disable root login (
PermitRootLogin no) so attackers can't target root directly. -
Rate-limit at the firewall:
sudo ufw limit OpenSSH(allows ~6 connections per 30s per IP, dropping brute-force spikes at the kernel level). -
Use a non-standard port (e.g., 2222) — reduces scanner traffic dramatically, though it's security-by-obscurity.
-
Restrict access to known admin IPs or a VPN (Tailscale/WireGuard) if your IP is static — then port 22 isn't exposed at all.
Before you change anything
-
Confirm key-based login already works from a fresh session before disabling passwords, or you'll lock yourself out.
-
Keep one SSH session open, back up the config (
cp, thensshd -tto validate syntax), thensudo systemctl reload ssh— not restart, so existing sessions survive. -
Check that your cloud provider has a web/serial console as a break-glass fallback.
Bottom line: there's nothing special or alarming in your numbers — it's the standard pre-scan traffic every internet-exposed server receives. If you want to reduce it (and the log noise), the fixes are key-only auth + disable root + firewall rate limiting. Once that's in place, the 1564 failures are wasted effort against a door that's already locked.
Want me to check whether any of the failed logins actually succeeded on a real account, or walk through a specific hardening step?
Yes — you should update fail2ban so its ban action targets your port 2010. The good news: fail2ban detects attacks by parsing your auth log, not by watching ports, so it still sees the failed logins on any port. The problem is only the ban itself — if fail2ban's action still blocks port 22 (or the OpenSSH app profile that points to 22), the banned IPs aren't actually being blocked from connecting to 2010.
What to change
On Ubuntu with UFW, the cleanest way is a dedicated UFW application profile for port 2010, then point the sshd jail at it.
1. Add an app profile for your port in /etc/ufw/applications.d/openssh-server:
2. Point the sshd jail at it in /etc/fail2ban/jail.local:
3. Reload and verify:
The port = 2010 line tells fail2ban the port to report/ban, and the action = ufw[application="OpenSSH-2010"] makes UFW insert a deny from <ip> to any app OpenSSH-2010 rule that actually drops traffic to 2010.
Important caveat
There's a known failure mode: if you leave fail2ban's default iptables/ufw action pointing at 22 or forget to update it, fail2ban-client status sshd will show bans, but ufw status will have no matching deny rules and the IPs keep reaching 2010 — exactly the "fails to block ssh on custom port" problem.
Two checks to confirm it's working after changing the port:
-
sudo fail2ban-client status sshd— shows the banned IP count. -
sudo ufw status numbered— verify a matchingDENY ... to 2010/tcp(orto ... app OpenSSH-2010) rule exists for recently banned IPs.
If you'd rather not maintain a custom profile, the alternative is the simpler stock line action = ufw with banaction = ufw under [DEFAULT] — but that still binds to the port = 2010 you set, so make sure that's updated.
One extra tip since you moved to 2010: add a second jail watching for activity on port 22 too — legacy scanners may still probe it, and banning them at 22 keeps noise out of your UFW logs.
Yes — just append that block to the end of /etc/ufw/applications.d/openssh-server. Adding a second [OpenSSH-2010] section alongside the existing [OpenSSH] (port 22) profile is fine; UFW supports multiple profiles in one file and each is referenced by its own bracketed name.
Append at the bottom:
Two quick notes:
-
Don't add a second
[OpenSSH]with the same name, or UFW will complain about a duplicate app — a uniquely-named block is the correct approach. -
After saving, re-read the profile list and confirm it appears:
Then you can use it in boththe firewall rule and the fail2ban action:
If ufw app list doesn't show the new profile after saving, just re-run sudo ufw app update OpenSSH-2010 (or reload UFW) to refresh its parsed application definitions.