I am trying to execute the ssh client command using SshNet package. Below codes hangs on RunCommand and Execute command and it won’t execute the command on target device.
- Using RunCommand
using (var duclient = new SshClient("ipaddress", 22, "admin", "admin")){
duclient.Connect();
string poweroff = duclient.RunCommand("show outlets").Result;
Console.WriteLine(poweroff);
duclient.Disconnect();
duclient.Dispose();
}
- Using CreateCommand and Execute
using (var duclient = new SshClient("ipaddress", 22, "admin", "admin")){
duclient.Connect();
SshCommand command = duclient.CreateCommand("show outlets");
command.Execute();
duclient.Disconnect();
duclient.Dispose();
}
But the manual connection using putty works and able to execute the commands. Below are the reference images.
Not understanding what is the issue with code. Please help me to understand the problem and how to resolve it.