Skip to content

Report SSH connect failures as SSH errors - #21

Merged
plajjan merged 1 commit into
mainfrom
ssh-error-types
Oct 29, 2026
Merged

plajjan merged 1 commit into
mainfrom
ssh-error-types

Conversation

@plajjan

@plajjan plajjan commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Client.on_connect reported every failure as a string and SshPipe turned each one into an OSError, so a key exchange mismatch with an old device looked like a socket failure. on_connect now gets an exception: an OSError only when the connect failed before the server's SSH banner, like a refused TCP connect, and otherwise an SshError. Its subclasses KeyExchangeError, HostKeyError and AuthenticationError are the failures that need a change on one side before a retry can succeed.

This changes the type of on_connect's err from ?str to ?Exception, so code that uses Client directly needs updating. SshPipe keeps the OSError for a failure before the banner and for the end of a connection, and reports the rest, including a refused channel, as an SshError.

StratoWeave will use this to retry a refused login or a key exchange mismatch slowly instead of every second, and to point ncurl users at the options that pick SSH algorithms.

Client.on_connect reported every failure as a string, and SshPipe made
each one an OSError, so a key exchange mismatch looked like a socket
failure. on_connect now gets an exception: an OSError only when the
connect failed before the server's SSH banner, like a refused TCP connect,
and otherwise an SshError. Its subclasses are the failures that need a
change on one side: KeyExchangeError when client and server share no
algorithm, HostKeyError when the host key is not trusted, and
AuthenticationError when the server refuses the credentials.

SshPipe passes the error on, and reports a refused channel as an SshError.
The end of a connection stays an OSError, as on TCP.

on_connect's err changes type from ?str to ?Exception.
@plajjan
plajjan merged commit e86b7f7 into main Oct 29, 2026
1 check passed
@plajjan
plajjan deleted the ssh-error-types branch October 29, 2026 17:20
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