SimpleSSHDemo was not crafted for Commands property, that's why you get disconnected error. I'll try to make a quick sample for you now.

SSH is a protocol where the data can come at any moment of time. So you need to poll the channel in some way. Timer is the simplest way, though if you have some kind of message loop, you can call SSHClient.CanReceive() there. You can call CanReceive() and Sleep() in a loop, but this would work only in non-UI thread (in UI thread this would block your UI).

I've put the updated CmdSSHDemo sample for C# (it existed for some time but was not included into the installation for some reason) here. The sample will be included into SecureBlackbox 10, so this link will not be actual with SBB 10 release.

It's possible that the problem is on the server side -- I tested the sample before posting it and it doesn't (and never did) show any errors.

With 2 commands issued, do you get response for both or disconnection happens after the first one?

Timer can't be removed from the sample for the reason I described - something should be used to poll the incoming data. If we replace the timer with some loop, we'll lose GUI responsiveness. If you need this functionality in non-UI code, that's a different story. In this case see ConsoleSSH sample.

Call CanReceive() method to check if there's anything to receive, then call ReceiveData() to actually receive the data.
Please note that it's possible that you have the unread data in the buffer and connection is already closed. So your simple loop will look like (in pseudo-C#)

Code

while (true)
{
if (SshClient.CanReceive(0))
SshClient.ReceiveData(...);

if (!SshClient.Active)
break;
}

Note that this will block your UI.

Also this code is good for one command. For multiple commands you will probably need to put it to separate method and call that method for each command. This will look like

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.