THREAT RADAR · TECHNICAL GUIDE

SSH brute force attacks: how to detect and protect your server

An Internet-exposed SSH service often receives automated login attempts. Meaningful investigation requires separating isolated failures, repeated attempts, targeted accounts, and genuinely successful sessions.

How SSH brute force attacks work

Attackers may repeatedly try to authenticate using common passwords or previously exposed credentials. Dictionary attacks use predefined candidates, while password spraying tests a few passwords across many accounts. Failed authentication does not prove a compromise.

  • Repeated attempts against one account
  • Attempts across different usernames or source addresses
  • Sustained activity or short bursts

Inspect Linux SSH authentication logs

On systemd-based servers, the SSH service journal can reveal failures and accepted sessions. The unit is commonly named ssh or sshd. Some distributions also record authentication activity in /var/log/auth.log or /var/log/secure.

sudo journalctl -u ssh --since '24 hours ago' --no-pager
sudo journalctl -u sshd --since '24 hours ago' --no-pager
  • Inspect Failed password and Invalid user entries
  • Review Accepted publickey and Accepted password separately
  • Correlate timestamps with targeted accounts

Failed attempts are not successful intrusions

A run of Failed password messages represents unsuccessful attempts. Accepted publickey or Accepted password entries require verification against authorized user activity. An IP address alone is not proof of malicious intent.

  • Verify successful sessions
  • Inspect account and configuration changes
  • Preserve reliable audit logs

Harden SSH access

Changes to SSH configuration should be validated before closing an active administration session. Protected SSH keys, restricted accounts, and network access controls reduce exposure.

sudo sshd -t
sudo ss -lntp | grep ':22'
  • Prefer properly secured SSH keys
  • Disable password login only after confirming key-based access
  • Restrict source networks using a firewall or VPN
  • Maintain an emergency access procedure

Reduce automated login attempts

Rate limiting, tools such as Fail2ban, and narrowly scoped firewall policies can reduce unsolicited login traffic. Tune them carefully to avoid locking out legitimate users.

  • Monitor false positives and blocks
  • Keep OpenSSH and the operating system updated
  • Document recovery access

Correlate IP addresses and observations

Distributed attempts are difficult to interpret one log line at a time. Comparing source IPs, ASNs, timing and repeated behavior improves context. Cloud hosting or ASN membership alone does not establish malicious activity.

  • Compare frequencies and time windows
  • Look for related events
  • Separate observation from attribution

Respond to suspicious successful access

Preserve evidence, review authorized keys and accounts, contain affected access and follow an incident response process. Coordinate secret rotation or restoration with the investigation.

  • Record a timeline
  • Inspect accounts and authorized keys
  • Revoke compromised credentials
  • Investigate persistence mechanisms

Frequently asked questions

Do failed SSH logins mean my server was hacked?

No. Authentication failures do not establish that a login succeeded.

Is changing the SSH port sufficient?

No. It may reduce automated noise but does not replace strong authentication and access restrictions.

How can I verify successful logins?

Find accepted authentication events in the SSH logs and compare them against expected administrative activity.

Does Threat Radar automatically block SSH attempts?

This guide does not claim a blocking feature. Check the functionality available in your subscription and configure server-side controls.