8,000 break-in attempts in one day: how I locked down my server
AI Bots tried to log in to my server more than 8,000 times in 24 hours. Here is exactly how I hardened it in one evening, and how you can do the same.
By Faysal Aziz
Edited and approved by Faysal Aziz
Published

I check the notifications (that I've been ignoring for the past few days due to some work that had kept me occupied) and to my shock, counted more than 8,000 failed login attempts in 24 hours. Nearly half of them were trying to get in as the most powerful account on the machine.
Was anyone targeting me personally? ....maybe / maybe not! That's irrelevant. I run a personal website, a small mail forwarder and an AI assistant...... perpetrators don't care who you are. They scan the whole system, find any part that answers, and start guessing passwords. Mine had been answering for with the doors wide open.
So I spent an evening locking it down. This is exactly what I did, why I did it, and how you can do the same on your own server.
Why this matters right now
Governments are bracing for more attacks, and that pressure spills onto everyone's machines.
- Malaysia raised its national cyber threat level from Low to Medium on 4 November 2026. Operators of critical systems were told to tighten up, including regular patching and multi-factor login. (Lowyat.NET)
- NACSA recorded 5,110 cyber security incidents in Malaysia from January to September 2026. (The Star)
- Governments became the most-hit sector worldwide, at 27% of the activity Microsoft observed, up from 17% the year before. (Microsoft)
NACSA makes a fair point: an attempted attack is not a breach. My 8,000 attempts were just that, attempts. But every attempt is a lottery ticket for the attacker, and an unhardened server keeps buying them tickets.
The big picture
No single setting saves you. Security comes in layers, so an attacker who gets past one still hits the next.

Logins and web traffic take different paths, but both must get through the firewall first, and patching sits under everything.
Step 1: Lock the front door (SSH)
SSH is how you log in to your server remotely, and it's where almost all of my 8,000 attempts landed.
What I found: root could log in directly with a password. Two settings files also disagreed with each other, and the wrong one was winning by accident.
What I changed: one small file of my own that is loaded first, so its values always win. I kept password login for my own user because that's how I like to work. Root can no longer log in directly; I log in as myself and switch to root with sudo when I need it.
# /etc/ssh/sshd_config.d/01-hardening.confPermitRootLogin noPasswordAuthentication yesKbdInteractiveAuthentication noX11Forwarding noMaxAuthTries 3
Why each line:
PermitRootLogin no: bots guessrootbecause every Linux server has it. Now that guess is worthless.MaxAuthTries 3: three wrong tries and the connection is dropped.X11Forwarding no: a feature for remote graphical apps that a web server doesn't need. Less to attack.
Do it safely:
- Keep your current session open the whole time.
- Check the file before applying it:
sudo sshd -t. No output means no errors. - Apply it with
sudo systemctl reload ssh. Reload keeps existing sessions alive. - Open a second terminal and log in again. Only close the first one when that works.
Step 2: Close every door you don't use (firewall)
My server had no firewall switched on at all. Every port was open to the whole internet.
The rule is simple: block everything coming in, then open only what your server actually serves. For mine that was SSH, the website and mail.
sudo ufw default deny incomingsudo ufw default allow outgoingsudo ufw allow 22/tcp # SSHsudo ufw allow 80/tcp # HTTP (redirects to HTTPS)sudo ufw allow 443/tcp # HTTPSsudo ufw allow 443/udp # HTTPS over HTTP/3sudo ufw allow 25/tcp # mail, only if you receive emailsudo ufw --force enable
The one rule that matters: add the SSH allow rule before you enable the firewall. Do it the other way round and you lock yourself out mid-sentence.
Why it helps: apps that should only talk inside the server (databases, admin panels, app servers) can't be reached from outside, even if one of them is set up wrong one day.
If you're on a cloud provider, keep its web console handy. It's your way back in if a rule ever goes wrong.
Step 3: Ban the guessers (fail2ban)
The firewall decides which doors exist. Fail2ban watches who keeps rattling the handle, and bans them.
I set it to three strikes: three wrong passwords within 10 minutes and that address is blocked for an hour.
sudo apt-get install -y fail2ban
# /etc/fail2ban/jail.d/sshd-hardening.local[sshd]enabled = truebackend = systemdmaxretry = 3findtime = 10mbantime = 1h
sudo systemctl enable --now fail2bansudo fail2ban-client status sshd
The result: it banned two attacking addresses within seconds of starting.
The catch: it will ban you too if you fat-finger your password three times. That's what the cloud console is for. Unban yourself with sudo fail2ban-client set sshd unbanip <your-ip>.
Step 4: Force HTTPS, every time
My web server already redirected http:// to https://. That still leaves one gap: the very first request goes out unencrypted, and someone on the same Wi-Fi can tamper with it before the redirect.
The fix is one header, HSTS. It tells the browser: for the next year, only ever talk to this site over HTTPS. I use Caddy, so it's one line inside the site block:
header Strict-Transport-Security "max-age=31536000"
On nginx it's add_header Strict-Transport-Security "max-age=31536000" always;
Two things to watch:
- Check the config before reloading (
caddy validateornginx -t), so a typo can't take the site down. - If a deploy script rewrites your web server config, add the header there too. Mine did, so I added it to the deploy template as well, or the next deploy would have quietly removed it.
Check it worked: curl -sI https://yoursite.com | grep -i strict
Step 5: Patch it and reboot
Automatic security updates were already running on my server, which was good. But 19 updates were waiting, and the server had been up for six weeks with a new kernel installed and never loaded. A kernel fix does nothing until you reboot.
sudo apt-get update && sudo apt-get upgrade -y[ -f /var/run/reboot-required ] && echo "reboot needed"sudo reboot
Before you reboot, check everything comes back by itself: systemctl is-enabled <service> for each app should say enabled. Apps that run under your own user also need "linger" turned on (loginctl show-user <you> -p Linger), or they won't start until you log in.
After the reboot, check every site loads and every service says active. Some apps are slow to start, so give them a few minutes before you panic.
Step 6: Deal with the regulars, then prove nothing broke
Block the regulars. One address had tried to log in as root every single hour for weeks, always with an old key type my server rejects. It turned out to be an internet research scanner. Harmless, probably, but I didn't invite it:
sudo ufw insert 1 deny from <address>
Check anything you expose to the web. I run an AI assistant with a web dashboard. It sits behind a password, and every new browser must also be approved from the server itself. That second lock matters: a password alone can be guessed.
Test what you care about, end to end. Hardening is only finished when you've proved the useful stuff still works:
- every site loads over HTTPS
- you can still log in from a fresh terminal
- email still arrives (I sent myself a test through the server, and it was delivered)
- apps that start slowly are back up
One tip from my own test: if your domain forwards email to Gmail, don't test it by sending from that same Gmail account. Gmail hides those copies from your inbox. Look in All Mail, or test from another account.
Write it down. I keep a log of what I found, what I changed and how to undo each change. Future me will thank present me.
Your checklist
- Root can't log in over SSH; at most 3 tries per connection
- Firewall on: deny incoming, allow only what you serve, SSH allowed first
- Fail2ban banning after 3 wrong passwords
- HTTPS forced with HSTS, also in any deploy template
- Updates installed, rebooted, every service back on its own
- Exposed dashboards need more than a password
- Logins, sites and email tested end to end
- A written log of every change and how to undo it
None of this needs to cost a cent. It took one evening, and the server is no longer an open invitation. Governments are raising their guard; we should raise ours.