I have developer a web application in asp.net .I use ssh.net to establish a connection between my application and the Cisco devices. i use the below code:
to connect
var ip = DropDownList2.SelectedItem.Text;
var user = txtuser.Text;
var passw = txtpass.Text;
var connInfo = new Renci.SshNet.PasswordConnectionInfo(ip, 22, user, passw);
var sshClient = new Renci.SshNet.SshClient(connInfo);
try
{
sshClient.Connect();
to run command i use 2 way:
2.1.
var cmd = sshClient.RunCommand("show user");
Label1.Text = cmd.Result;
its work fine withe router and switch but not working with firewall for that i try to use shellStream :
2.2.
var ss = this.shellStream;
sshClient.Connect();
this.shellStream = sshClient.CreateShellStream("dumb", 80, 24, 800, 600, 1024);
Console.WriteLine(SendCommand("enable", ss));
Console.WriteLine(SendCommand(passw, ss));
Console.WriteLine(SendCommand("show looging", ss));
i can send multiple command to divice but my probbleme is how to display the result of this command from the shellStream. i try some thing like that but is not working
string reslt = Console.ReadLine();
Label1.Text = Reslt;
i try to mixed this 2 way like this
this.shellStream = sshClient.CreateShellStream("dumb", 80, 24, 800, 600, 1024);
Console.WriteLine(SendCommand("enable", ss));
Console.WriteLine(SendCommand(passw, ss));
Renci.SshNet.SshCommand cmd;
cmd = sshClient.RunCommand("show logging");
txtenablepass.Text = cmd.Result;
but is not working and i have this Exception
Additional information: Failed to open a channel after 10 attempts.
my question is how display the output in textbox from the shellStream ?