We earn commissions when you shop through affiliate links on this site, at no extra cost to you. Our guides and technical recommendations are written independently of these relationships: a commission never decides what we recommend, how we diagnose a problem or what we publish, and the content does not depend on it. Affiliate disclosure

Use cases · Published 2026-11-13

What Happens When You Expose SSH to the Internet

We left two key-only SSH servers open to the internet for 12 hours and watched the log: who knocked, what they tried, and what one firewall rule changed.

You have just put a server on the internet. It has a public address, port 22 is open so you can log in, and you set it up the careful way: no passwords, keys only. Now you wonder what actually happens out there. Does anyone notice? Does anyone care?

We did not want to answer from folklore, so we ran an experiment. Two disposable test servers, left reachable on port 22 from anywhere, watched for 12 hours like a night-shift guard with a log book.

TL;DR

  • Visitors arrived within minutes. On this night, the busiest hour had about 50 hostile lines on one server and the quietest hour had at least one. There was no quiet hour on either server.
  • Nobody got in. Every successful login came from our own address. No new users, no extra keys, no scheduled jobs.
  • A key-only server has no "Failed password" lines, and that is normal. We counted zero. The log was still full of visitors; they show up as closed connections instead.
  • fail2ban banned very few of them (two networks on one server, one on the other, out of 40 and 55 that touched them). The technical reason gets its own follow-up runbook.
  • A machine of ours on a home network, with the same SSH setup, showed no line from a public address in its journal since 1 November. It is on only while the computer runs, so this is a weak comparison.
  • Limiting the port to one address left no lines from other addresses at the next check, four minutes later.

The setup

Two small test servers in one cloud region, one running Ubuntu 26.04 and one running RHEL 10.2. Both accepted SSH public keys only: passwords and keyboard-interactive logins were off, and root could log in only with a key. Both ran fail2ban. The cloud firewall rule for port 22 allowed every source.

The window ran from 20:25 UTC on 12 November to 08:25 UTC on 13 November. The window overlapped the Microsoft 365 incident of 12 to 13 November 2026, which began about 16:17 UTC on the 12th and was still open on the morning of the 13th; the data here shows nothing about any connection.

Think of it as a front door on a busy street. The door is locked and only keys work. We wanted to know how many people try the handle.

The first knock

It did not take long. The first hostile lines showed up within minutes of the port opening, before anyone could have bookmarked our address.

That is the first thing to understand if you are new to this: on the internet, "nobody knows my server exists" is not a security plan. We did not trace who the visitors were. Many different addresses trying the same short list of common user names is what automated scanning looks like.

The night, hour by hour

The log book had entries at every hour. Over the 12 hours, the Ubuntu server logged 225 lines from the SSH service (10 of them our own) and the RHEL server 413 (4 of them our own).

Behind those lines:

Ubuntu 26.04RHEL 10.2
Distinct hostile addresses4968
Distinct hostile /24 networks4055
Lines naming the user root97166

root was the favorite name by a wide margin, followed by admin. After that came a long tail of names that read like a list of things people hope a server has: user, test, system, oneadmin, ubuntu, config, ubnt, git, Administrator. The bots do not know which names exist on your machine. They try the common ones and move on.

A page from the log book

Enough counting. This is what the Ubuntu server actually wrote, picked from different hours of the night. Nothing is edited except that each visitor address became <ip>, the server name became host and the process number became pid. The yellow parts are the ones to look at.

# Real lines from the Ubuntu server, UTC time, picked from different hours (address replaced with <ip>)
11-12T22:09:43 host sshd-session[pid]: Connection closed by authenticating user root <ip> port 50766 [preauth]
11-12T22:24:18 host sshd-session[pid]: Unable to negotiate with <ip> port 64304: no matching key exchange method found. Their offer: [...] [preauth]
11-12T23:00:31 host sshd-session[pid]: error: kex_exchange_identification: read: Connection reset by peer
11-13T00:06:50 host sshd-session[pid]: banner exchange: Connection from <ip> port 53130: invalid format
11-13T02:28:41 host sshd-session[pid]: Invalid user admin from <ip> port 56178
11-13T02:28:42 host sshd-session[pid]: Connection closed by invalid user admin <ip> port 56178 [preauth]
11-13T08:00:29 host sshd-session[pid]: error: maximum authentication attempts exceeded for root from <ip> port 43614 ssh2 [preauth]

Read it like a night-shift report, one line at a time:

  • 22:09, root and [preauth]. A visitor named the user root and left before logging in. Lines like this were among the most common of the night.
  • 22:24, no matching key exchange method found. Usually that means the software of the visitor offered only methods this server no longer accepts, so the two could not agree how to start.
  • 00:06, invalid format. Something connected to port 22 and did not speak SSH at all.
  • 02:28, Invalid user admin. The visitor tried a name that does not exist on this machine, then left, again before authentication finished.
  • 08:00, maximum authentication attempts exceeded. One visitor made more attempts as root than the server allows and was cut off.

The RHEL server wrote the same story in a slightly different accent:

# Real lines from the RHEL server, same night, same masking
11-12T20:30:43 host sshd-session[pid]: Connection closed by authenticating user adm <ip> port 40294 [preauth]
11-12T20:42:00 host sshd-session[pid]: Invalid user git from <ip> port 58166
11-12T20:42:02 host sshd-session[pid]: Connection closed by authenticating user root <ip> port 52284 [preauth]
11-12T20:51:47 host sshd-session[pid]: Invalid user default from <ip> port 36668
11-13T07:49:09 host sshd-session[pid]: Invalid user ubuntu from <ip> port 52516

Over the whole night the raw log files held Invalid user 14 times on Ubuntu and 48 times on RHEL, and preauth 131 and 267 times. Failed password appears zero times in both.

A few visitors were stranger than that:

  • Banner junk. Six lines on each server say banner exchange: invalid format: something outside connected to port 22 and did not speak SSH. A scanner that knocks on the SSH door and then recites something else is a bit like someone ringing the bell and reading out a shopping list. We did not find out what it was.
  • Scanners with old manners. On the Ubuntu server, ten lines say no matching key exchange method. Usually that means the visitor's software offered only encryption methods the server no longer accepts. We counted 10 on the Ubuntu server and none on the RHEL server and did not check why.
  • Doors tried and abandoned. Many connections were simply closed before the visitor named a user (40 lines on Ubuntu, 37 on RHEL) or were reset (32 and 71).

The night-shift summary: a lot of bots, one door, and a door that only takes keys.

What a "failed login" is when only keys are allowed

Most new admins look for one line and do not find it. On a password server, a bot guessing passwords leaves Failed password lines. We counted Failed password and Failed publickey on both servers: zero, zero, zero, zero. Failed key attempts are not logged at the default log level, so those zeros need care, as explained below.

That zero does not mean the bots stayed away. With passwords and keyboard-interactive switched off, the server offers only one way in: a key. A bot that came to guess a password has nowhere to type one, and the server cuts the connection at the authentication step. No password was ever evaluated. Failed key attempts are not logged at the default log level, so a zero for Failed publickey does not mean none were made: four lines on the Ubuntu server say maximum authentication attempts exceeded.

What remains in the log is the lines in the yellow blocks above: the ones that end in [preauth].

preauth means "this happened before authentication finished". The visitor named a user, the server offered only keys, and the visitor closed the connection before authentication finished. Most likely a bot that wanted a password and found none. The log line does not say why the visitor left. If you grep your log for Failed password on a key-only server and see nothing, you have not learned that nobody visited; you have learned that you are grepping for the wrong sentence.

fail2ban and its small number

fail2ban watches the log and bans addresses that misbehave. After 12 hours its totals were small: the Ubuntu server banned two networks, the RHEL server banned one. Against 40 and 55 networks that actually touched the servers, that is a small share.

Replaying the recorded log through fail2ban's default filter, it matched 20 of 239 lines on Ubuntu and 48 of 439 on RHEL, roughly a tenth. The replay used the journal as recorded at 08:35 UTC, so its line totals are slightly higher than the table above.

Its whole night of work on the Ubuntu server, taken from fail2ban's own log, was these two lines:

# Real lines from fail2ban's own log on the Ubuntu server, the only two bans of the night
11-13 08:00:32,141 fail2ban.actions [pid]: NOTICE  [sshd] Ban <ip>
11-13 08:10:55,574 fail2ban.actions [pid]: NOTICE  [sshd] Ban <ip>

The first one came about eleven and a half hours after the port opened. For a long time the log book had plenty of entries and fail2ban had nothing to write.

A small ban count on a key-only server does not mean a quiet server, and fail2ban is not the lock on the door. The technical reasons, a script to measure your own server and the safe fix are the subject of a follow-up runbook we publish next.

The control: a machine with no visitors

To see whether the lines depended on being reachable from outside, we looked at a lab machine of ours: Ubuntu 26.04 with the same key-only SSH setup, on a home network behind a router. We forwarded no port to it, but we did not check from outside whether it was reachable. Its journal went back to 1 November and held 820 SSH lines. It is only on while the computer runs, so this is not a continuous 12 hours.

We looked at every line for an address on the public internet. There were none. The 268 lines that mentioned Invalid user or preauth all came from the machine itself or the private test network, which was our own generated test traffic.

That fits the idea that the hostile lines came from being reachable at a public address. It is one machine, switched on part of the time, and we did not test reachability.

The morning

The window closed at 08:25 UTC. After that, and before we changed the firewall rule at 08:37, we looked for damage. There was none. Every Accepted line came from our address; there were no new users, no extra entries in authorized_keys, no cron jobs.

At 08:37 UTC we changed the cloud firewall rule on both servers from "any source" to our own single address. At 08:41 UTC, four minutes later, there were no SSH lines from any other address on either server, and no established connection on port 22 from any other address. The log showed no line from anyone else at that check.

Then we deleted both servers and everything attached to them.

What this means for your server

  • Expect visitors early. On our one night, visitors arrived within minutes of the port opening. We did not trace who they were, so we cannot say why.
  • Keys only held. Nobody got in. We cannot say what a weak password would have cost, because we never allowed one.
  • Limit who can reach port 22 if you can. That is what left no lines from other addresses at our check. For doing it without locking yourself out, read Troubleshoot Linux firewall access safely.
  • Read the right lines. Search for preauth and Invalid user, not Failed password.

What we have not verified

  • The counts are one 12-hour window, one region of one cloud provider, one night. They are a shape, not a rate for other days or places.
  • The /24 groupings are by network prefix, not by owner. We did not look up location or organization.
  • No password login was ever allowed, so there is no data on weak passwords.
  • We did not test from outside whether the lab machine was reachable. No port was forwarded to it on the router.
  • The lab machine was on only while the computer was on, so its quiet record is not a continuous window.
  • We did not check why the Ubuntu server saw old-key-exchange scanners and the RHEL server did not.
  • The damage check has no recorded time beyond the gap between 08:25 and 08:37 UTC.
  • The overlap with the Microsoft 365 incident is timing only.

Related guides

Sources

  • sshd_config(5)
  • Observation notes: two cloud test servers, 12 November 2026 20:25 UTC to 13 November 2026 08:25 UTC.

More from the blog

This article is educational information, not incident-response or legal advice. Verify package status with your operating system, hosting, or runtime vendor.