I stumbled into a bug when using passwords with special characters. I can reproduce the bug with the following code:
using (SshClient client = new SshClient("host" /* existing */, "user" /* existing */ , "tést" /* mention the é */))
When using the password “test” (without é), everything works fine, however when including the special character, Connect() will not return. It does not matter whether the password is correct or wrong.
I was not able to track down the bug in the source code, nor have I found any relationship to the special characters. But I located the problem in Session.WaitHandle:
internal void WaitHandle(WaitHandle waitHandle)
var waitHandles = new WaitHandle
var index = EventWaitHandle.WaitAny(waitHandles, this.ConnectionInfo.Timeout);
if (index < 1)
else if (index > 1)
this.SendDisconnect(DisconnectReason.ByApplication, "Operation timeout");
throw new SshOperationTimeoutException("Session operation has timed out");
For some reason, WaitAny will trigger the timeout. The deathlock then occurs during the stack unwinding while throwing the SshOperationTimeoutException.
Does anyone have a fix or a workaround for this problem?