我想创建一个应用程序来向HP交换机和其他设备发送SSH命令。但是从HP交换机我得到响应"SSH命令执行不受支持“。
我使用代码的这一部分。
SshClient sshclient = new SshClient(IP,username, pass);
sshclient.Connect();
SshCommand sc = sshclient.CreateCommand("conf");
sc.Execute();
string answer = sc.Result;
label9.Text = answer;有什么想法吗?如何进行交互的shell仿真?关于这个问题,我只找到了这条线索。phpseclib - attempting to connect to an HP procurve switch returns error: SSH command execution is not supported
发布于 2017-07-21 21:20:11
一般来说,您的代码是正确的。但是,似乎特定的设备不支持SSH "exec“通道,这是SshCommand类背后的内容。
正如answer to the question you have linked yourself所建议的,不幸的是,您必须使用SSH " shell“通道来模拟shell。
为此,请使用SshClient.CreateShell并将命令写入其输入流。
请注意,这只是一个解决您的具体情况的方法。一般情况下,“外壳”通道不得用于自动化。
https://stackoverflow.com/questions/45227308
复制相似问题