Understanding brute-force attacks
As soon as a server exposes an authentication service on the Internet, it receives automated attempts. This is not a targeted attack, it is background noise: bots try common credentials on SSH, login forms and APIs. Recognising it prevents confusing that normal pressure with a real intrusion.
What the logs show
sudo journalctl -u ssh -n 100 --no-pager
sudo grep "Failed password" /var/log/auth.log | tail -n 20
sudo grep -c "Failed password" /var/log/auth.log
sudo lastb | headTypical lines mention invalid user admin, root or random names, followed by Failed password. On a minimal install without rsyslog, /var/log/auth.log may be absent: journalctl is then the reliable source. Hundreds of attempts per day on a public IPv4 address are ordinary. What matters are Accepted lines: a successful login from an unknown address is the signal to examine first.
Why keys change the game
A password attack only has leverage if password authentication is enabled. A properly protected Ed25519 key cannot be guessed. Order matters:
- install your key and test it in a second session;
- set
PasswordAuthentication noandPermitRootLogin prohibit-passwordin/etc/ssh/sshd_config.d/; - validate with
sudo sshd -t, then reload the service; - keep the first session open until confirmed.
Changing the SSH port reduces log noise but is not a security measure on its own: a scan finds the port within minutes.
Reduce the surface
AllowUsersrestricts which accounts may log in.MaxAuthTries 3andLoginGraceTime 20limit attempts per connection.ufw limit 22/tcpapplies simple rate limiting if UFW is in place.- Fail2ban temporarily bans an address after several failures.
sudo apt install fail2ban
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.localIn jail.local, adjust the duration and threshold, and above all add your admin address to ignoreip before enabling:
[DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 5
ignoreip = 127.0.0.1/8 YOUR_ADMIN_IP
[sshd]
enabled = trueThen check status with sudo fail2ban-client status sshd. Without an allowlist, a configuration mistake can ban you.
React to a successful attempt
If you find an unknown Accepted line, treat the server as compromised: check ~/.ssh/authorized_keys, users (/etc/passwd), cron jobs, processes and outbound connections. Change passwords and keys, then consider a reinstall if binaries were modified. Restarting the service is not enough: the access persists.
Other targets
Web login forms, wp-login.php, APIs and SMTP face the same pressure. Protect them with strong authentication, rate limiting at the Nginx layer and, where possible, two-factor authentication. If traffic saturates your VPS, contact support: upstream network filtering does not replace a correctly configured application.
Advertisement
Was this article helpful?
Read next
- Monitor a VPS with htopRead htop indicators correctly, identify a heavy process and act without breaking the service.
- Create your first NeoHeberg VPSChoose the plan, create the service and connect for the first time.
- Diagnose a VPS that will not bootUse the console, read the previous boot log and fix disk, fstab or packages before reinstalling.