Home / Guides

Server guide

Thousands of failed SSH logins: what to do

Every public server gets password guesses all day. The question is not whether they try. It is whether any of them got in.

2 min readUpdated November 2026 by the RootManage teamWorks on Ubuntu, Debian, AlmaLinux and Rocky unless noted

The short answer

Failed attempts are normal. Check that no login succeeded from an address you do not know, then switch to SSH keys, turn off password login and add Fail2ban or a firewall rule.

See the attempts

terminal
sudo grep 'Failed password' /var/log/auth.log | awk '{print $(NF-3)}' | sort | uniq -c | sort -rn | head
sudo lastb | head

On systems without auth.log, use sudo journalctl -u ssh --since yesterday. On Red Hat family systems the file is /var/log/secure.

Check what matters: successful logins

terminal
last -n 20
sudo grep Accepted /var/log/auth.log | tail

Do you recognise every address and time? An unknown success is an incident. Change passwords and keys, check for new users, new cron jobs and unknown processes, and ask for help.

Lock it down

  • Use SSH keys and set PasswordAuthentication no in /etc/ssh/sshd_config.
  • Set PermitRootLogin no and use a normal user with sudo.
  • Restrict who can log in with AllowUsers.
  • Limit the source addresses in the firewall if you have a fixed address.
  • Install Fail2ban or CSF to block repeated failures.

Other steps

  • Change the SSH port if you like. It reduces noise but is not real security.
  • Turn on two-step login for the control panel and hosting account.
  • Keep the system updated.

Test before you close the session

Open a second terminal and test a new login before you log out. A wrong SSH setting can lock you out. Keep a console login ready.

Questions people ask

Is it dangerous to have many failed logins?

Not by itself. Strong keys and no password login make guessing useless. The risk is a weak password that is guessed.

Does Fail2ban stop attacks?

It slows guessing and keeps logs clean. It does not replace keys.

What if I find a login I do not know?

Treat the server as compromised: change credentials, check users and cron jobs, keep logs, and get help before you rebuild.

Want a person to look at it?

Tell us what you see. We reply with what we think is wrong and what it would take to fix it.