Repeated failed SSH logins can indicate a brute-force attempt to guess account credentials. This guide explains how to inspect Linux authentication logs and distinguish failed attempts from evidence of a successful login.

Inspect recent SSH logs

You need administrator permission to read authentication logs. On systems that record SSH messages in the systemd journal, try the unit used by your distribution:

sudo journalctl -u sshd --since '1 hour ago' --no-pager

On systems using ssh.service, use:

sudo journalctl -u ssh --since '1 hour ago' --no-pager

If the distribution writes authentication logs to files, inspect the appropriate file instead:

sudo grep 'Failed password' /var/log/auth.log
sudo grep 'Failed password' /var/log/secure

auth.log is commonly used on Debian and Ubuntu; secure is commonly used on RHEL-family systems. File logging depends on the server’s configuration, and these commands do not include rotated logs.

Review the pattern

Look for repeated failures, invalid usernames and a large number of attempts within a short period. Compare the timestamps, source addresses and targeted users. Review Accepted login messages around the same time to identify successful connections you do not recognise.

Check existing monitoring

Where the system records failed sessions in btmp, this command can provide another view:

sudo lastb

If Fail2Ban is already configured, list its jails before checking the SSH jail:

sudo fail2ban-client status
sudo fail2ban-client status sshd

Use the actual jail name from your configuration. A banned address is a result of those rules, not proof that the server was compromised.

Investigate unexpected successful logins and protect the log evidence. For hardening, test key-based access and recovery access before disabling passwords or changing SSH settings.