Executing Powershell command through freeSSHd is blocking SSH.NET

Sep 22, 2013 at 9:41 AM
Edited Sep 23, 2013 at 12:42 AM
The SSH.NET library is locking up when I run a Powershell script through freeSSHd. Executing VBScripts through cscript works without issue. I have included example C# code for both (see below). In both cases, the scripts simply involves writing a string to STDOUT.

Stepping into the code, the code is blocking on Session.SocketRead after the SSH_MSG_CHANNEL_DATA message occurs. More specifically, executing the VBScript command generates a SSH_MSG_CHANNEL_REQUEST message, but executing the Powershell command does not.

I have tested the command line in a Command Prompt as well as executing it through an SSH client (putty) without issue. Can anyone give me a workaround or confirm whether this is a bug in the SSH.NET or freeSSHd?

// This works without issue
var client = new Renci.SshNet.SshClient("", "username", "password");
var command = client.CreateCommand("cscript.exe /nologo C:\test.vbs");

// This blocks
var client = new Renci.SshNet.SshClient("", "username", "password");
var command = client.CreateCommand("PowerShell.exe C:\test.ps1");

'VBScript script
WScript.Echo "This is my output"

#Powershell script
Write-Host "This is my output"

Update: I also duplicated this behavior using Bitvise SSH Server (WinSSHD)