T160: Implement hostkeys-00@openssh.com global request
Description
Originally reported by asn: https://bugs.libssh.org/T160
Implement hostkeys-00@openssh.com global request. It is an extension implemented by OpenSSH to allow clients to synchronize the host keys the server is currently using after successful authentication.
Follows below the specification:
connection: hostkey update and rotation "hostkeys-00@openssh.com" and "hostkeys-prove-00@openssh.com"
OpenSSH supports a protocol extension allowing a server to inform a client of all its protocol v.2 host keys after user-authentication has completed.
byte SSH_MSG_GLOBAL_REQUEST
string "hostkeys-00@openssh.com"
string[] hostkeys
Upon receiving this message, a client should check which of the supplied host keys are present in known_hosts.
Note that the server may send key types that the client does not support. The client should disregard such keys if they are received.
If the client identifies any keys that are not present for the host, it should send a "hostkeys-prove@openssh.com" message to request the server prove ownership of the private half of the key.
byte SSH_MSG_GLOBAL_REQUEST
string "hostkeys-prove-00@openssh.com"
char 1 /* want-reply */
string[] hostkeys
When a server receives this message, it should generate a signature using each requested key over the following:
string "hostkeys-prove-00@openssh.com"
string session identifier
string hostkey
These signatures should be included in the reply, in the order matching the hostkeys in the request:
byte SSH_MSG_REQUEST_SUCCESS
string[] signatures
When the client receives this reply (and not a failure), it should validate the signatures and may update its known_hosts file, adding keys that it has not seen before and deleting keys for the server host that are no longer offered.
These extensions let a client learn key types that it had not previously encountered, thereby allowing it to potentially upgrade from weaker key algorithms to better ones. It also supports graceful key rotation: a server may offer multiple keys of the same type for a period (to give clients an opportunity to learn them using this extension) before removing the deprecated key from those offered.
Comments:
Jakuje commented on 2020-10-05 07:58:30 UTC:
FYI, this is now enabled by default in OpenSSH's HEAD, which will probably make it in release in ~6 months. This would make it very useful for libssh to support now.
https://lists.mindrot.org/pipermail/openssh-unix-dev/2020-October/038869.html