sshd "fatal: userauth_pubkey: parse publickey packet: incomplete message"
Published
sshd could not read the public-key authentication request the client sent — the packet ended before its fields were parsed, so the per-connection process logged a fatal error and dropped the client without checking any key.
What it looks like
Nov 12 03:51:11 web1 sshd-session[48211]: fatal: userauth_pubkey: parse publickey packet: incomplete message [preauth]
- 1Time — When it was logged; this format has no year or time zone
- 2Host — The server’s host name
- 3Program — sshd-session, one process per connection, and its process ID: a connection’s lines share it
- 4[preauth] — Logged before the user authenticated
Example lines as /var/log/auth.log shows them (/var/log/secure on RHEL and Fedora):
Nov 12 03:51:11 web1 sshd-session[48211]: fatal: userauth_pubkey: parse publickey packet: incomplete message [preauth] Nov 12 03:51:14 web1 sshd-session[48217]: fatal: userauth_pubkey: parse publickey packet: incomplete message [preauth]
On our own server, the 30 days to 23 November 2026
parse … packet
13
lines · about 0.43 a day
Last seen 23 November 2026
LogTriage's production API server (Hetzner, Germany): port 22 open to the internet, key-only since 6 October 2026 (password and keyboard-interactive authentication off); nginx in front of the API on ports 80 and 443. Counted weekly from the sshd journal; no address ever leaves the server. More in the monthly attack report; which free blocklists already list these attackers is measured in the IP blocklist report, and you can check the addresses in your own log.
Where the line comes from
Format strings as written in the source of OpenSSH 10.2p1 — the versions this server runs. Each links to the exact line.
-
parse %s packetmessage · auth2-pubkey.c:111 (OpenSSH) -
userauth_pubkey(struct ssh *ssh, const char *method)function name, logged as the prefix · auth2-pubkey.c:92 (OpenSSH) -
incomplete messageerror text appended to the message · ssherr.c:33 (OpenSSH)
What it means
The line comes from one call in OpenSSH’s public-key authentication handler, auth2-pubkey.c:
userauth_pubkey()reads three things out of the client’s userauth request — a one-byte flag saying whether a signature is included, the public key algorithm name, and the key blob itself (lines 108-110).- If any of those reads fails, line 111 calls
fatal_fr(r, "parse %s packet", method). The fatal variant prefixes the function name, so the message readsuserauth_pubkey: parse publickey packet:and then appends the text of the error code. %sis the method name the client selected.publickeyis the plain method; the hostbound method[email protected]would appear in the same slot, and its extra host key field has its own message,parse %s hostkey.- The trailing text is
ssh_err()’s string for the failure.incomplete messageis ssherr.c’s wording forSSH_ERR_MESSAGE_INCOMPLETE: the packet ran out of bytes before the fields were read.
So the client got through key exchange, chose the publickey method, and then sent a request sshd could not decode. Because the call is fatal, the sshd-session process handling that connection logs the line and exits — the client is disconnected and no key is ever examined. The [preauth] suffix marks the message as written before authentication completed.
Two things make the line awkward in triage: it names no source address, no port and no account, and it is a protocol-level complaint rather than a credential verdict. Nothing in it can tell you whether a login succeeded, and it cannot be evidence of password or key guessing.
Is it an attack?
| Pattern | Reading |
|---|---|
| A handful of lines, one or two PIDs, from a host you control | A client library or automation tool building the userauth packet wrongly, or a session cut mid-packet |
| Repeats at a fixed interval | A broken job retrying — find it by PID and by what else it logged |
| Bursts of lines, many PIDs, other malformed-protocol messages alongside (unable to negotiate, banner format errors) | Something is sending deliberately malformed SSH, typical of fuzzers and protocol scanners |
Mixed with Accepted publickey for the same account minutes later | The client eventually got it right; check what the session did, not the parse error |
Rare lines are noise. The condition worth escalating is volume: a sustained stream from the internet means someone is testing how your sshd handles broken input, which belongs with the rest of your scanning telemetry rather than with brute-force alerts.
How to investigate
# Every parse failure for the publickey method (RHEL/Fedora: /var/log/secure)
sudo grep 'userauth_pubkey: parse publickey packet' /var/log/auth.log
# Same from the journal (Debian/Ubuntu unit is ssh; RHEL/Fedora: -u sshd)
sudo journalctl -u ssh --since "7 days ago" | grep 'parse publickey packet'
# Which error text did ssh_err() return?
sudo grep -o 'parse publickey packet: .*' /var/log/auth.log | sort | uniq -c | sort -rn
# The line carries no address - pull everything that connection logged, by PID
sudo grep 'sshd-session\[48211\]' /var/log/auth.log
# Hour buckets: one broken client looks different from a burst of fuzzing
sudo grep 'parse publickey packet' /var/log/auth.log | cut -c1-9 | sort | uniq -c
If the PID produced no other line, you have no source address to work with. LogLevel defaults to INFO; raising it to VERBOSE makes sshd more talkative about connections, so repeat offenders become attributable. Exported auth.log can be grouped by process and message in the browser log analyzer.
How to stop it
- Fix the client first. If the PID belongs to your own CI runner, backup agent or an SSH library, the server is behaving correctly; the sender is producing an invalid publickey request. Reproduce with
ssh -vvvfrom the same host and compare. - Do not disable public keys.
PubkeyAuthenticationdefaults toyes, and on a key-only host turning it off removes your only way in. - Narrow who may reach the service. Put a firewall or allowlist in front of port 22, and use
AllowUsers, which restricts login to matching user names — by default, per sshd_config(5), “login is allowed for all users”. TheUSER@HOSTform also accepts CIDR host criteria. - Leave penalties on.
PerSourcePenaltiesis enabled by default with the documented settings; thecrashclass refuses clients “that cause a crash of sshd(8)” for 90s by default. The manual does not state which class a fatal parse error falls under, so treat penalties as background hygiene rather than a control you can rely on for this message. - Alert on rate, not on presence. A single line is a broken client; a sudden climb in lines per hour is worth a look alongside your other scanning signals.
sudo sshd -t && sudo systemctl reload ssh
Validate the configuration before reloading, and keep an existing session open until a new one works.
Does fail2ban ban it?
fail2ban’s sshd filter does not count this line as a failure in any mode.
- normal (default)not counted
- ddosnot counted
- extranot counted
- aggressivenot counted
fail2ban 1.1.1's sshd filter on the first example line above. Test your own lines in the fail2ban regex tester →
Lines you will see next to it
- … for … from … port … ssh2… sshd authenticated the named account — the line records a completed SSH login with the method used, the user, the client address and source port, and for public keys the key type and fingerprint that was accepted.
- kex_exchange_identification(struct ssh *ssh, int timeout_ms, sshd never finished the opening banner exchange with the client — the other end went away (or sent something unreadable) before sending its identification string, so the connection ended before key exchange and before any authentication.
- …Connection … sshd dropped the connection during the opening protocol banner exchange because what the client sent could not be parsed — almost always something that is not an SSH client at all.
- Connection closed by … The client at the other end of the SSH connection went away — closed it cleanly, or reset it — and sshd logged the address, port and (if the client had already named an account) the user it was trying before it quit.
Detect it
MITRE ATT&CK: T1595
Frequently Asked Questions
- Does this line mean someone tried to log in with a key?
- The client asked for the publickey method, but sshd never got as far as reading a key. The three fields read at auth2-pubkey.c:108-110 are the signature flag, the public key algorithm name and the key blob; the parse failed while reading them, so there is no fingerprint, no account check and no authentication outcome on this connection.
- Why is there no IP address or user name on the line?
- The format string is only `parse %s packet`, wrapped by the fatal variant that prefixes the function name `userauth_pubkey` and appends the error text. No address or account is interpolated. To find out who sent it, correlate on the `sshd-session[PID]` of the line with the other messages that same process wrote.
- Is the trailing text always "incomplete message"?
- No. The text is whatever `ssh_err()` returns for the parse failure, and the same table in ssherr.c also returns strings such as "invalid format" and "string is too large". LogTriage counts any trailing text after "parse publickey packet:", so check which variant your own log actually holds before drawing conclusions.
- Did sshd crash when it logged "fatal"?
- The listening server keeps running. Each connection is handled by its own sshd-session process, and it is that process which logs the fatal error and exits, so the effect is one dropped connection. Other sessions in progress and new connections are unaffected.
Run your own auth.log through it
Paste or drop /var/log/auth.log (or journalctl -u ssh output) into the free browser analyzer: brute force, password spraying, a successful login after failures and invalid-user sweeps are flagged with the evidence lines. Nothing is uploaded.
Investigating something right now? LogTriage checks every address in the file against threat intelligence and writes the incident report: 10 analyses a month free. The incident pack adds the in-depth AI analysis and files up to 100 MB: 25 analyses for $19, one payment, no subscription. Pricing
How this page was made. The official definitions, field names and examples on it are copied by script from the sources it links and re-checked against them on every build. The counts come from the logs of our own internet-facing server, refreshed weekly. The investigation advice was drafted with AI from those sources and passed a separate review before publishing. What is checked, and how · found a mistake? [email protected]