diff --git a/contrib/win32/openssh/sshTelemetry.c b/contrib/win32/openssh/sshTelemetry.c index d3a7406e7..7dfbf4acf 100644 --- a/contrib/win32/openssh/sshTelemetry.c +++ b/contrib/win32/openssh/sshTelemetry.c @@ -119,6 +119,19 @@ void send_encryption_telemetry(const char* direction, TraceLoggingUnregister(g_hProvider1); } +void send_kex_exch_exit_code_telemetry(const int exit_code) +{ + TraceLoggingRegister(g_hProvider1); + TraceLoggingWrite( + g_hProvider1, + "KexExchExitCodeSSHD", + TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), + TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), + TraceLoggingInt16(exit_code, "KexExchExitCodeSSHD") + ); + TraceLoggingUnregister(g_hProvider1); +} + void send_pubkey_telemetry(const char* pubKeyStatus) { TraceLoggingRegister(g_hProvider1); @@ -205,4 +218,3 @@ void send_ssh_version_telemetry(const char* ssh_version, ); TraceLoggingUnregister(g_hProvider1); } - diff --git a/contrib/win32/openssh/sshTelemetry.h b/contrib/win32/openssh/sshTelemetry.h index eee14d701..69a905054 100644 --- a/contrib/win32/openssh/sshTelemetry.h +++ b/contrib/win32/openssh/sshTelemetry.h @@ -12,6 +12,9 @@ void send_encryption_telemetry(const char* direction, const char* comp, const char* host_key, const char** cproposal, const char** sproposal); +// sends exit code of kex_exchange_identification(), utilized only in sshd +void send_kex_exch_exit_code_telemetry(const int exit_code); + // sends status if using key-based auth void send_pubkey_telemetry(const char* pubKeyStatus); diff --git a/sshd.c b/sshd.c index 9ecc7e94b..ad27b61f2 100644 --- a/sshd.c +++ b/sshd.c @@ -2723,8 +2723,16 @@ done_loading_hostkeys: alarm(options.login_grace_time); if ((r = kex_exchange_identification(ssh, -1, - options.version_addendum)) != 0) + options.version_addendum)) != 0) +#ifdef WINDOWS + { + send_kex_exch_exit_code_telemetry(r); +#endif /* WINDOWS */ sshpkt_fatal(ssh, r, "banner exchange"); +#ifdef WINDOWS + } + send_kex_exch_exit_code_telemetry(0); +#endif /* WINDOWS */ idexch_done: ssh_packet_set_nonblocking(ssh);