I am attempting to remote into a virtual controller to run aruba commands into the console such as "show run" etc but no output is coming up for the commands. It appears I am able to successfully connect, and I am not seeing any errors, but nothing happens when running a command.
I have connected via putty to validate the commands, and also validate credentials. I have been able to do similar functionality via python, but am needing to be able to do this via C# for dependency reasons.
var methods = new List<AuthenticationMethod>();
methods.Add(new PasswordAuthenticationMethod(UserName, Password));
var con = new ConnectionInfo(virtualController, 22, UserName, methods.ToArray());
Console.WriteLine("Attempting Connection with Network...");
var Client = new SshClient(con);
Client.Connect();
Console.WriteLine("Successfully Connected.");
var cmdRun = Client.RunCommand(showClients);
var result = cmdRun.Result;
Console.WriteLine(result);
cmdRun = Client.RunCommand(showRun);
result = cmdRun.Result;
Console.WriteLine(result);
Client.Disconnect();
The console outputs "Successfully Connected." and continues to execute all code, but never outputs anything on the line:
Console.WriteLine(result);
I would expect for the terminals output that I would see when running this command via putty.
I use SSHClient
instead of Client
. Using my class from this answer , here's some sample code after calling Client.Connect()
:
SSHStream = SSHClient.CreateExtShellStream("dumb", 120, 80, 0, 0, 65536);
if (SSHStream != null) {
DoCommand("no page");
Connected = true;
}
var result = DoCommand("show cdp neighbors | begin Port", TimeSpan.FromSeconds(2), "#");
Here is the helper method:
public static IEnumerable<string> DoCommand(string c, TimeSpan? timeout = null, string prompt = "#") {
return SSHStream.DoCommand(c, timeout ?? TimeSpan.FromSeconds(2), prompt);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.