Skip to content

docs: the known_hosts steps keep ssh-keyscan's comment lines on newer OpenSSH #100

Closed

Description

@groupsky

What happened

On 2026-10-20, the known_hosts steps of docs/setup.md section 6 were run on a Debian 13 broker host, with the guide's pattern:

ssh-keyscan -t ed25519,ecdsa,rsa HOST 2>/dev/null |
  awk '{print "NAME", $2, $3}' >> /run/nodkey-setup/known_hosts

The broker then refused to start:

config /etc/nodkey/broker.toml: known_hosts: /etc/nodkey/known_hosts: line 1: the key is not valid base64

The ssh-keyscan of that host wrote its banner comment lines (# HOST:22 SSH-2.0-OpenSSH_...) to stdout, not stderr, so 2>/dev/null kept them. The awk turned each one into NAME HOST:22 SSH-2.0-OpenSSH_..., a line that looks like a host line. On the same day, OpenSSH 9.6 on Ubuntu 24.04 wrote no comment to stdout. So this depends on the OpenSSH version.

Step 3 of the guide does not catch it: ssh-keygen -lf skips the bad lines without a word, so the fingerprint list looked right.

Fix

  • Keep only the key lines, for example awk '$1 !~ /^#/ {print "NAME", $2, $3}', or filter by key type.
  • In step 3, also compare the number of lines of the file with the number of fingerprints.
  • Maybe also: make the broker's error say what it found ("the third field is not a key; is this a comment from ssh-keyscan?").

Done when

  • Section 6 keeps only key lines, whichever stream ssh-keyscan writes its comments to.
  • Step 3 would show a line that is not a key.
  • The OpenSSH version that writes the comments to stdout is named, with a source.

Activity

  1. groupsky commented on Nov 9, 2026

    @groupsky
    ContributorAuthor

    Fixed by #163 (squash commit d6157d7), docs/setup.md section 6.

    • Section 6 keeps only key lines, whichever stream ssh-keyscan writes its comments to: step 2 now uses awk '$1 !~ /^#/ {print "NAME", $2, $3}'. Checked by hand on a scan with a banner line: the file gets only the key lines.
    • Step 3 would show a line that is not a key: it compares wc -l of the file with ssh-keygen -lf ... | wc -l, and gives an awk command that prints each line whose second field is not a key type, with its line number. Checked by hand: the old pattern gave 3 lines and 2 fingerprints, and the command showed line 1.
    • The OpenSSH version is named, with a source: OpenSSH 9.8 and later, openssh-portable commit 1e84d0c (2024-06-14, first in tag V_9_8_P1). Its message says "to stderr", but its code moves the lines from stderr to stdout; the guide says this. Ubuntu 24.04 has 9.6, so it writes them to stderr.

    Not done: the better broker error (the issue said "maybe"). The docs fix and the count check meet Done when.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions