[sshd] Log the full KEX negotiation result

Apache MINA sshd doesn't log all values, but it'd be very helpful to
debug KEX problems.

Change-Id: I5a19023c929f39caccde489d51a6fdca711fe5ff
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
Thomas Wolf 2021-06-19 15:41:37 +02:00
parent 79d86c4a57
commit ce61341bd1
1 changed files with 19 additions and 0 deletions

View File

@ -39,6 +39,7 @@
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.io.IoWriteFuture;
import org.apache.sshd.common.kex.KexProposalOption;
import org.apache.sshd.common.util.Readable;
import org.apache.sshd.common.util.buffer.Buffer;
import org.eclipse.jgit.errors.InvalidPatternException;
@ -200,6 +201,24 @@ public void messageReceived(Readable buffer) throws Exception {
}
}
@Override
protected Map<KexProposalOption, String> setNegotiationResult(
Map<KexProposalOption, String> guess) {
Map<KexProposalOption, String> result = super.setNegotiationResult(
guess);
// This should be doable with a SessionListener, too, but I don't see
// how to add a listener in time to catch the negotiation end for sure
// given that the super-constructor already starts KEX.
//
// TODO: This override can be removed once we use sshd 2.8.0.
if (log.isDebugEnabled()) {
result.forEach((option, value) -> log.debug(
"setNegotiationResult({}) Kex: {} = {}", this, //$NON-NLS-1$
option.getDescription(), value));
}
return result;
}
@Override
protected String resolveAvailableSignaturesProposal(
FactoryManager manager) {