Repository navigation
Report SSH connect failures as SSH errors - #21
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.