Skip to content

Add support for host key updating & rotation with hostkeys-00@openssh.com & hostkeys-prove-00@openssh.com

These changes add support for the hostkeys-00@openssh.com and hostkeys-prove-00@openssh.com messages for both the server and the client so that host updates and rotation work.

This allows for SSH servers to be able inform clients of new keys without breaking existing configurations with an error that the host key doesn't match. OpenSSH has implemented this for a while and with https://github.com/openssh/openssh-portable/commit/1286981d08b8429a64613215ce8bff3f6b32488a it will also be the default behavior for the next OpenSSH release.

The changes are best reviewed commit by commit, which are each for separate steps. A few things of note that I want to call out specifically:

  • Usage of SSH_BIND_OPTIONS_HOSTKEY with ssh_bind_options_set is slightly extended. Before there was a last call wins mechanism and previously configured keys were ignored. The last call wins mechanism is still present, but now previously set keys are retained in a separate list and sent as host keys for a server. This allows for rotating an SSH host key of an existing type, so for example for a new RSA host key.
  • Behavior of ssh_session_update_known_hosts has been slightly changed. Before it would end up adding an existing key as a new entry on each call and it of course didn't know about additional host keys received. The new behavior is that ssh_session_update_known_hosts doesn't add any existing entries to the hosts file, and that it also writes out any received new host keys through the host keys extensions. I don't think this presents a backwards compatibility breaking change though.

Any existing users of libssh won't see a behavior change by default, as ssh_server_send_hostkeys is needed in a server implementation to send out host keys. In a client, ssh_message_request_hostkeys_prove is needed to ask for proof of received host keys.

I'm not sure about the scan-build failures in the pipeline here. They don't seem to be new, but maybe detection fails due to some code being moved? That causes different line numbers, but afaik there are no new issues added / introduced.

Checklist

  • Commits have Signed-off-by: with name/author being identical to the commit author
  • Code modified for feature
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated

Reviewer's checklist:

  • Any issues marked for closing are addressed
  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to CONTRIBUTING.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code

Merge request reports

Loading