Blog
Learn how an SSH banner check proves a server is alive, why it catches failures that ping and TCP checks miss, and how to handle firewalls, fail2ban and custom ports.
SSH server monitoring means opening a TCP connection to the SSH port from outside and checking that the daemon sends its identification banner, a line like SSH-2.0-OpenSSH_9.6. If that line arrives within a few seconds, the host is up, the network path works and sshd is running and responding, all without logging in. It fills the gap between ping, which many networks block, and HTTP checks, which only work on machines that serve web traffic.
This guide covers what a banner check proves, how to set one up with commands you can test today, how to read its failure modes and what to watch on the security side, including servers that run SSH on non-standard ports.
The SSH protocol (RFC 4253) has the server send an identification string as soon as the TCP connection is established, before any key exchange or authentication. The client does not need to send anything first. That makes the banner check a cheap, unauthenticated proof of life.
$ nc -w 5 db1.example.com 22
SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13
^CWhen that line comes back, several things are true at once: the host is powered on, its kernel and network stack work, firewalls along the route allow the port, and the sshd process is running with enough resources to accept a connection and write to it.
This is where a banner check is stronger than a plain port check. The kernel completes the TCP handshake on its own and parks the connection in the listen backlog until the application accepts it. A daemon that is frozen, swapping or stuck can leave the port looking open for a while. A TCP check proves the kernel accepted the connection; a banner check proves sshd itself is alive and answering.
What it does not prove: that authentication works, that a given user can log in, that the disk has free space or that the applications on the host are healthy. Treat it as a liveness signal for the machine and its management access, not as a service check.
Each layer answers a different question. The trade-offs between ICMP and web checks are covered in ping monitoring vs HTTP monitoring. SSH adds a third angle that is especially useful on servers without a web front end.
The combination is what helps during an incident. Reading the results together narrows down the failing layer before anyone opens a terminal:
The last case is easy to miss without an SSH check, and it tends to surface at the worst moment: during the next outage, when you need to log in and cannot.
ss -tlnp | grep ssh and note any bastion or jump host that fronts private machines.nc -w 5 host port shows the raw banner, ssh-keyscan -p port host confirms the key exchange starts, and ssh -v -o ConnectTimeout=5 host shows where a connection hangs.SSH-2.0- and nothing more. Matching the full version string breaks every time the package is updated.If you want to script the check yourself, for example from an internal monitoring host, this Python snippet reads the banner and exits non-zero on failure. It tolerates servers that send extra lines before the version string, which the protocol allows.
import socket, sys
host = sys.argv[1]
port = int(sys.argv[2]) if len(sys.argv) > 2 else 22
try:
with socket.create_connection((host, port), timeout=5) as s:
s.settimeout(5)
data = b""
while b"SSH-" not in data and len(data) < 1024:
chunk = s.recv(256)
if not chunk:
break
data += chunk
except OSError as e:
sys.exit(f"CRITICAL: {host}:{port} {e}")
for line in data.split(b"\n"):
if line.startswith(b"SSH-2.0-"):
print("OK:", line.strip().decode(errors="replace"))
sys.exit(0)
sys.exit(f"CRITICAL: no SSH-2.0 banner from {host}:{port}")Call it as python3 ssh_banner.py db1.example.com 2222 from your check runner and alert on a non-zero exit code. The probe disconnects before key exchange, so it never touches authentication.
The failure type tells you more than the fact that the check failed.
The no-banner case deserves a closer look. MaxStartups limits concurrent connections that have not finished authentication. The OpenSSH default 10:30:100 means sshd starts dropping new unauthenticated connections with increasing probability once 10 are pending. During a brute-force wave, your monitor can see dropped connections while the host is otherwise fine. If that happens regularly, the fix is reducing exposure with firewall rules or allowlists, not loosening the alert.
A banner check never authenticates, and it should not. Do not put a key or password into a monitoring tool just to check liveness. The banner already proves what you need, and a stored credential is one more thing that can leak.
If SSH is only reachable from specific IPs, add the source addresses of your monitoring probes to the allowlist, or the check fails permanently. If SSH is only reachable over a VPN or private network, an external check cannot see it. In that case run the check from inside the network and report the result outward, for example to a heartbeat monitor that expects a regular ping from your internal checker, so a dead checker also raises an alert.
Every check leaves a short pre-authentication line in the auth log, because the probe connects and closes without logging in. fail2ban and similar tools may count these lines against the probe, depending on the filter mode, and eventually ban it. The result looks like an SSH outage that only your monitor sees. Exempt the probe addresses:
# /etc/fail2ban/jail.local
[sshd]
ignoreip = 127.0.0.1/8 ::1 203.0.113.10 203.0.113.11Use the actual probe addresses of your monitoring setup. The ones above are documentation examples.
The banner shows the SSH software version. Anyone who connects already sees it, so monitoring it exposes nothing new. It can even be useful: an unexpected version change tells you a package was updated or the host was replaced. Log it, but do not treat it as a failure.
If SSH is hidden behind port knocking, a banner check fails by design. Monitor such hosts with an internal check and a heartbeat instead of opening an exception that defeats the purpose.
Moving SSH to a port like 2222 cuts down log noise from automated scanners, though it is not a security control on its own. For monitoring, it introduces a few ways to break checks:
sshd_config. Verify with ss -tlnp instead of trusting the config file.semanage port -a -t ssh_port_t -p tcp 2222.A banner check is the quickest way to confirm from outside that a port move worked. Because it validates the SSH-2.0- prefix, it also catches a new port that is open but answered by something else. For the general logic of port checks and where they stop, see TCP port monitoring and how to combine it with HTTP checks.
If you prefer not to maintain your own checker, m0nitor provides an SSH monitor type alongside HTTP(S), TCP, ping, DNS and heartbeat monitors as part of its uptime monitoring. Checks run from distributed probes in several regions, and an outage is confirmed by multiple locations before an alert fires (multi-region consensus), which filters out single-route network blips. Any external checker that reads the banner and confirms failures from more than one location serves the same purpose; the steps above apply either way.
No. The server sends its identification banner before any authentication, so a liveness check only needs to connect, read one line and disconnect. Storing keys or passwords in a monitoring tool adds risk without adding signal.
It is better than nothing, but it only proves the kernel completed the handshake. A hung or overloaded sshd can leave the port open while never answering. Reading and validating the SSH-2.0- banner closes that gap at almost no extra cost.
Yes. Each check produces a pre-authentication log entry, and depending on the filter, fail2ban may count it as a failed attempt. Add the probe addresses to ignoreip in the sshd jail, otherwise the monitor reports an outage that exists only for the banned probe.
Yes, if you rely on SSH to manage them. HTTP checks tell you whether users are served; the SSH check tells you whether the machine and your access to it are healthy. When HTTP fails and SSH still answers, you already know the host is up and the problem sits in the web or application layer.