The SSH.NET library is locking up when I run a Powershell script through freeSSHd and WinSSHD. Executing VBScripts through cscript.exe 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("127.0.0.1", "username", "password");
client.Connect();
var command = client.CreateCommand("cscript.exe /nologo C:\test.vbs");
command.Execute();
// This blocks
var client = new Renci.SshNet.SshClient("127.0.0.1", "username", "password");
client.Connect();
var command = client.CreateCommand("PowerShell.exe C:\test.ps1");
command.Execute();
'VBScript script
WScript.Echo "This is my output"
#Powershell script
Write-Host "This is my output"
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("127.0.0.1", "username", "password");
client.Connect();
var command = client.CreateCommand("cscript.exe /nologo C:\test.vbs");
command.Execute();
// This blocks
var client = new Renci.SshNet.SshClient("127.0.0.1", "username", "password");
client.Connect();
var command = client.CreateCommand("PowerShell.exe C:\test.ps1");
command.Execute();
'VBScript script
WScript.Echo "This is my output"
#Powershell script
Write-Host "This is my output"