diff --git a/src/Renci.SshNet/ConnectionInfo.cs b/src/Renci.SshNet/ConnectionInfo.cs index 02e817b24..023546948 100644 --- a/src/Renci.SshNet/ConnectionInfo.cs +++ b/src/Renci.SshNet/ConnectionInfo.cs @@ -187,6 +187,14 @@ public class ConnectionInfo : IConnectionInfoInternal /// public int MaxSessions { get; set; } + /// + /// For servers that wait for the Key Exchange message, send the SSH_MSG_KEXINIT explicitly on connect() + /// + /// + /// True to initiate the key exchange on connect(). Default is false. + /// + public bool InitiateKeyExchange { get; set; } + /// /// Occurs when authentication banner is sent by the server. /// @@ -341,6 +349,7 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy ChannelCloseTimeout = DefaultChannelCloseTimeout; RetryAttempts = 10; MaxSessions = 10; + InitiateKeyExchange = false; Encoding = Encoding.UTF8; KeyExchangeAlgorithms = new Dictionary diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs index c984d3109..41ea907eb 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -650,6 +650,11 @@ public void Connect() // ToDo: Make message pump async, to not consume a thread for every session _ = ThreadAbstraction.ExecuteThreadLongRunning(MessageListener); + if (ConnectionInfo.InitiateKeyExchange) + { + SendMessage(ClientInitMessage); + } + // Wait for key exchange to be completed WaitOnHandle(_keyExchangeCompletedWaitHandle);