2

I would like to create an application to send SSH commands to HP Switches and some other devices. But from HP Switch I get response "SSH command execution is not supported.".

I use this part of a code.

SshClient sshclient = new SshClient(IP,username, pass);
sshclient.Connect();
SshCommand sc = sshclient.CreateCommand("conf");
sc.Execute();
string answer = sc.Result;
label9.Text = answer;

Any ideas how to make the interactive shell emulation? I found only this thread regarding to this issue. phpseclib - attempting to connect to an HP procurve switch returns error: SSH command execution is not supported

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Marek Kyzivát
  • 323
  • 2
  • 16

1 Answers1

1

Your code is correct in general. But it seems, that the particular device does not support the SSH "exec" channel, what is behind the SshCommand class.

As the answer to the question you have linked yourself suggests, you have to unfortunately emulate a shell by using SSH "shell" channel.

For that use SshClient.CreateShell and write the command to its input stream.

Note that this is just a workaround for your specific situation. In general, the "shell" channel shall not be used for automation.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992