Blog

SSH server monitoring: banner checks as a liveness signal, why they complement ping and HTTP, and non-standard ports

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.

What does an SSH banner check actually prove?

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
^C

When 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.

Why SSH checks complement ping and HTTP

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.

  • Ping tells you the kernel answers ICMP. It is often filtered by cloud firewalls and can keep working when userland processes are dead.
  • HTTP tells you the web stack serves a correct response. Database hosts, queue workers, build runners and bastion hosts usually have no HTTP endpoint at all.
  • SSH tells you a userland daemon on the host accepts and answers connections, and that you will be able to get in to fix things.

The combination is what helps during an incident. Reading the results together narrows down the failing layer before anyone opens a terminal:

  • Ping, SSH and HTTP all fail: host down, broken network path or a firewall change. Check the provider console first.
  • Ping works, SSH and HTTP fail: the kernel is alive but userland is in trouble, often memory exhaustion or a hung system.
  • SSH works, HTTP fails: the machine is fine, the web server, the app or its upstream is not. Log in and look at the service.
  • HTTP works, SSH fails: users are not affected yet, but you have lost management access.

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.

How to set up SSH server monitoring step by step

  1. List the hosts and the real SSH port of each. Do not assume 22. Check on the server with ss -tlnp | grep ssh and note any bastion or jump host that fronts private machines.
  2. Test from outside, from a machine that is not in your office network or VPN. 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.
  3. Decide what counts as success. Match the prefix SSH-2.0- and nothing more. Matching the full version string breaks every time the package is updated.
  4. Set timeouts. Use a connect timeout of 5 to 10 seconds and a similar read timeout for the banner. On a healthy host the banner normally arrives in a fraction of a second, so a slow banner is a warning sign in itself.
  5. Pick an interval. One check per minute is a reasonable default for production servers. Less critical hosts can be checked every few minutes.
  6. Require confirmation before alerting: at least two consecutive failures, ideally seen from more than one region. The reasoning is the same as in reducing false positive alerts with multi-region checks and retries.
  7. Route the alert to whoever can act on the host, and include host, port and the failure type (refused, timeout, no banner) in the message.

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.

How to read SSH check failures

The failure type tells you more than the fact that the check failed.

  • Connection refused: the host is up and answered with a reset, but nothing listens on that port. sshd stopped, crashed or moved to another port.
  • Connection timeout: no answer at all. The host is down, routing is broken, or a firewall or security group drops the packets.
  • Connected, but no banner before the timeout: the kernel accepted the connection, sshd did not respond. Typical causes are a hung or overloaded host, heavy swapping, or sshd shedding new unauthenticated connections because of MaxStartups.
  • Unexpected banner: something else answers on the port, for example after a port conflict, a load balancer in front or a wrong NAT rule.

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.

Security considerations for SSH monitoring

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.

Firewalls and allowlists

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.

fail2ban and log noise

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.11

Use the actual probe addresses of your monitoring setup. The ones above are documentation examples.

Version disclosure

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.

Port knocking and single packet authorization

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.

Monitoring SSH on non-standard ports

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:

  • The monitor still points at port 22 after the move. During a migration, check both ports until the old one is closed on purpose.
  • On some recent distributions sshd is started through systemd socket activation, so the listening port can come from the socket unit rather than sshd_config. Verify with ss -tlnp instead of trusting the config file.
  • With SELinux enforcing, sshd cannot bind to a new port until it is labeled: semanage port -a -t ssh_port_t -p tcp 2222.
  • Cloud security groups and host firewalls need the new port opened for both admins and monitoring probes.

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.

Running SSH checks with a hosted monitor

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.

FAQ

Does SSH server monitoring need login credentials?

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.

Is a TCP check on port 22 enough to monitor SSH?

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.

Can monitoring probes get banned by fail2ban?

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.

Should I monitor SSH on servers that already have HTTP checks?

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.

Product

  • Pricing
  • Features
  • Integrations
  • Security
  • Free network check

Features

  • Uptime monitoring
  • Status pages
  • Alert workflows
  • Incident management
  • Dependencies
  • AI assistant
  • Global infrastructure
  • On-call schedules
  • Enterprise SSO

Use cases

  • Websites for free
  • Cron jobs
  • SSL certificates
  • Databases
  • IP blacklists
  • GDPR compliance

Resources

  • What is a status page?
  • Documentation
  • API
  • MCP server
  • Monitoring glossary
  • Free tools
  • SLA calculator
  • SSL checker
  • DNS lookup
  • Blog
  • Changelog
  • About
  • Contact

Compare

  • Free uptime monitoring
  • UptimeRobot
  • Better Stack
  • Pingdom
  • StatusCake
  • Uptime Kuma
  • Hyperping
  • Atlassian Statuspage
  • Instatus
  • Cachet
  • Freshping