Skip to content

Conversation

@ZoltanFridrich
Copy link

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 length
What 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.

Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
@djmdjm
Copy link
Contributor

djmdjm commented Nov 25, 2025

Looks good to me. @daztucker ok?

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.

2 participants