sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.88k stars 919 forks source link

Send the client key exchange init in Connect #1274

Closed Rob-Hague closed 6 months ago

Rob-Hague commented 6 months ago

After discussion in #972, I have been running this in production against several different servers for a week or so.

An example key exchange with this change:

image

And an example when the server init comes in first:

image

cc @geoffstewart

WojciechNagorski commented 6 months ago

I will check this next week.

Rob-Hague commented 6 months ago

@BoronBGP @expyram perhaps you could test this on a cisco device? Bonus points for pasting the packet trace

WojciechNagorski commented 6 months ago

Can we prepare tests to cover two cases? When does server initialization occur and when does it not?

Rob-Hague commented 6 months ago

Added a unit test for when the server does not send kexinit

edit:

When does server initialization occur and when does it not?

The RFC says "Key exchange (kex) begins by each side sending name-lists of supported algorithms." I.e. there is no indication that the client or server should wait for the other.

SSH.NET currently waits for the server to send its supported algorithms. This works OK against most server implementations, but if the server is waiting for SSH.NET, then we have a problem.

WojciechNagorski commented 6 months ago

The 2023.0.1 version has been released to Nuget: https://www.nuget.org/packages/SSH.NET/2023.0.1