By Phil Chiu, founder · Published March 14, 2026 · Last verified: October 23, 2026

To protect SSH from brute force, turn off password logins and require SSH keys, keep root password login disabled, and limit who can reach port 22 at the firewall. Then add fail2ban or CrowdSec to ban repeat offenders and cut log noise. A firewall IP blocklist is an optional extra layer, not a replacement.

Any server with port 22 open to the internet gets automated login attempts, because bots scan the IPv4 address space looking for SSH. MITRE ATT&CK tracks this as Brute Force: Password Guessing (T1110.001). The attack is old and simple, and it still works against servers that accept passwords.

This guide covers why SSH is targeted, what the attempts cost you even when they fail, and the defenses in order of impact, with the exact sshd_config settings to use.

What Is an SSH Brute Force Attack?

An SSH brute force attack is an automated attempt to get shell access to a server by guessing username and password combinations against the SSH daemon, usually on port 22. Attackers run it from botnets and rented servers, scanning for open SSH ports and then guessing credentials against every server they find.

The attack is simple. The bot connects to port 22, tries a common username (root, admin, ubuntu, deploy) with a password from a list of common or leaked credentials, then repeats. Spread across many source IPs, the attempts add up and each IP can stay below per-IP ban thresholds.

Unlike VPN brute force attacks that target web-based login portals, SSH brute force attacks target the SSH protocol directly. A web application firewall (WAF) does not see them; they have to be stopped at the network or host level.

See it on your own server: on Debian or Ubuntu, run grep -E 'Failed password|Invalid user' /var/log/auth.log | tail -n 20. On RHEL-based systems the file is /var/log/secure. Systems without a syslog file keep the same lines in the journal: journalctl -u ssh (the unit is sshd on RHEL).

Why SSH Is a Common Target

SSH is one of the most common brute force targets on the internet, for several reasons:

The Damage Beyond Compromised Servers

Even when attackers never guess a correct password, SSH brute force attacks cause significant operational damage:

CPU and Memory Load

Each SSH authentication attempt consumes CPU cycles on your server. The SSH daemon must accept the TCP connection, perform the SSH handshake, and process the authentication attempt. With many attempts per hour, this adds load, which is most noticeable on low-powered cloud instances and IoT devices with limited resources.

Log Flooding

Every failed SSH login writes entries to /var/log/auth.log (or /var/log/secure on RHEL-based systems, or the systemd journal). During a sustained campaign these logs grow quickly, use disk space, and bury the legitimate authentication events you actually need to find. If you ship logs to a service that charges by volume, the noise also costs money.

Fail2ban Overhead

Many administrators run Fail2ban to ban IPs after repeated failed logins. It works well against single noisy IPs, but it has to parse every log line and add a firewall entry per ban. With the plain iptables actions each ban is a separate rule, so long ban lists slow packet processing; the ipset and nftables set-based actions scale much better and are worth switching to if you ban many IPs.

The Fail2ban gap: Fail2ban is reactive. It lets each IP fail several times before banning it. When a botnet spreads its attempts across many IPs and each makes only a few tries, those IPs may never cross the threshold, and the guessing continues.

Lateral Movement Risk

If an attacker does compromise one server over SSH, the damage rarely stops there. Private keys and known_hosts files on that server can point to, and sometimes unlock, other machines. Internal SSH is often configured less strictly than internet-facing SSH, which makes moving from one compromised host to the next easier. This is why key hygiene matters as much as stopping the first login.

SSH Defenses in Order of Impact

Start with the changes that remove password guessing outright, then add the layers that cut exposure and noise.

1. Key-Only Authentication

Disabling password authentication and requiring SSH keys is the most effective single change. With passwords off, password brute force cannot succeed because there is no password to guess, and the server stops offering the password method to clients.

To deploy: generate a key pair for each user (ssh-keygen -t ed25519), copy the public key to the server (ssh-copy-id or configuration management), and confirm you can log in with the key. Then set these in /etc/ssh/sshd_config (see the OpenSSH sshd_config manual):

sshd uses the first value it reads for each setting, and many distributions include /etc/ssh/sshd_config.d/*.conf near the top of the main file, so a drop-in file (for example one written by cloud-init) can override your change. Run sshd -t to check the syntax, sshd -T | grep -i passwordauthentication to see the value sshd will actually use, then reload the service. Keep your current session open until a fresh key login works.

2. Restrict Who Can Reach Port 22

If only known people and systems need SSH, allow port 22 only from their addresses at the cloud security group or firewall, or put SSH behind a VPN or a bastion host. Traffic from everyone else never reaches sshd, which removes most of the noise as well as the risk.

3. Fail2ban or CrowdSec

Fail2ban watches the SSH log and bans IPs that fail too many times within a time window. Its stock jail.conf defaults are 5 failures within 10 minutes for a 10-minute ban; put your own values in jail.local so package updates do not overwrite them. Longer bans and the incremental bantime.increment option help against IPs that come back.

CrowdSec does local detection in a similar way and can also apply a community blocklist built from detections shared by other CrowdSec users. Both are reactive at the local level: an IP has to misbehave on your server, or on others in the CrowdSec community, before it is blocked.

4. SSH Certificates (Larger Fleets)

Instead of managing individual public keys on every server, you run an SSH Certificate Authority (CA) that signs short-lived user certificates. Servers trust the CA through TrustedUserCAKeys, and users authenticate with certificates that expire after hours or days. This removes key sprawl and simplifies revocation, and like key-only auth it leaves no password to guess.

Tools such as HashiCorp Vault, Teleport, and Smallstep can issue SSH certificates. It is the most work of anything on this list, because it involves CA infrastructure, identity-provider integration, and changing how every user connects.

5. Change the SSH Port (Noise Reduction)

Moving SSH from port 22 to a non-standard port cuts the log noise from bots that only try the default port. Set Port in sshd_config, open the new port in your firewall before reloading sshd, and on SELinux systems label it with semanage port -a -t ssh_port_t -p tcp 2222. Some recent distributions start sshd through systemd socket activation, so check your distribution’s notes on changing the port.

Important caveat: this is obscurity, not a security control. A port scan finds the new port quickly. Treat it as noise reduction and keep the measures above in place.

6. Firewall IP Blocklist (Optional Extra Layer)

An IP blocklist loaded on your firewall, for example as an External Dynamic List (EDL), drops listed IPs at the perimeter so their connections never reach sshd. It only helps against IPs that are already on the list.

Be clear about what the ThreatListPro list is: it comes from real attacks on live production Palo Alto GlobalProtect VPN portals in the US, so it is not an SSH-specific feed. It covers SSH attackers only where the same sources also attack VPN portals. If you run a VPN portal as well as SSH servers, one firewall rule can apply it to both; see the firewall setup guides, or use the IP checker to see whether addresses from your own SSH logs are on the list.

Where Firewall-Level Blocking Fits

Each defense acts at a different point. Fail2ban blocks at the host, after sshd has already handled some failed attempts. Key-only auth rejects the login during the SSH handshake. A port change reduces noise but does not stop a targeted attacker. A firewall rule acts before the connection reaches the server at all.

That gives perimeter blocking (an allowlist for port 22, or a blocklist) some real advantages:

A blocklist is not a replacement for key-only authentication or for restricting who can reach port 22. Do those first. A blocklist is worth adding where it overlaps the attackers you actually see.

Frequently Asked Questions

What is an SSH brute force attack?

An SSH brute force attack is an automated attempt to log in to an SSH server by trying many username and password combinations, usually against port 22. Bots scan the internet for open SSH ports and then guess credentials. Because SSH gives shell access, one guessed password can hand an attacker control of the machine.

How many SSH brute force attempts will my server see?

It depends on the server, its IP range and how long port 22 has been open, so there is no reliable single number. Count your own: on Debian or Ubuntu run grep -c 'Failed password' /var/log/auth.log, on RHEL-based systems use /var/log/secure, or read the journal with journalctl -u ssh (the unit is sshd on RHEL).

What is the most effective way to protect SSH from brute force?

Turn off password logins and require SSH keys: set PasswordAuthentication no and KbdInteractiveAuthentication no in sshd_config, test with sshd -t, then reload sshd. With no password to guess, password brute force cannot succeed. Then restrict port 22 at the firewall to the addresses that need it, and add fail2ban or CrowdSec to cut log noise.

Should I change my SSH port?

Moving SSH off port 22 cuts the noise from bots that only try the default port. It is not a security control: a port scan finds the new port quickly. Treat it as noise reduction and keep key-based authentication and firewall restrictions in place.

Can ThreatListPro protect SSH servers?

Partly. ThreatListPro's list comes from real attacks on live production Palo Alto GlobalProtect VPN portals in the US, so it is not an SSH-specific feed. It blocks SSH attackers only where the same sources also attack VPN portals. For SSH, use key-only authentication plus fail2ban or CrowdSec; add ThreatListPro at the firewall if you also run a VPN portal.

SSH Brute Force Protection Methods Compared

MethodWhat it stopsEffortProactive?Cost
SSH Key Auth OnlyPassword guessing, entirelyLow per serverYes — no passwords to guessFree
Firewall allowlist for port 22All traffic from addresses you did not allowLow, if users have fixed IPs or a VPNYes — port closed to othersFree
Fail2BanRepeat offenders seen in local logsLow to mediumNo — reactive after failed loginsFree (open source)
CrowdSecLocal offenders plus IPs reported by other usersMediumPartly — community list blocks before contactFree (open source); paid tiers
Port KnockingHides SSH from scannersMediumYes — port closed until knockFree
IP Blocklist (ThreatListPro)Listed IPs from VPN portal attacks (5.4M+ IPv4 addresses); SSH only where sources overlapA few minutesYes, for listed IPs$9.99/month, 14 days free, no card needed