Ignore bad hostkeys in known_hosts file #567
Open
+18
−0
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.
When a short ssh-rsa hostkey is present in known_hosts, the connection will fail with the following error:
Bad server host key: Invalid key lengthWhat happens is that the ssh-rsa key is found in known_hosts file and is picked as prefered keyalg. Then when server sends its short rsa key, the verify_hostkey check fails and the error is printed. The connection fails even if valid keys are present on the server.
This patch changes the behavior to ignore bad hostkeys when scanning known_hosts file. The result is that a helpful message is printed into debug (example:
debug2: record_hostkey: /root/.ssh/known_hosts:1: ignoring hostkey: Invalid key length) and the connection can be established by accepting new keys.