Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Created Unassigned: Issue with "enable" on Cisco devices [2578]

$
0
0
I have an issue with passing password to Cisco devices when trying to get to enable mode.
It detects prompt ">" correctly, then "enable" command is sent, but whole thing stops on sending password to device.

Same time, when user lands in enable shell with # as prompt everything works fine.

Passing password works fine on Linux when issuing "su - root". That has no problems.

Only Cisco enable mode is causing trouble.

Maybe someone had similat experience. Code I'm using is below.

```
ssh = new SshClient(this.HostName, this.UserName, this.UserPassword);
ssh.Connect();

stream = ssh.CreateShellStream("dumb", 80, 24, 800, 600, 1024);
reader = new StreamReader(stream);
writer = new StreamWriter(stream);
writer.AutoFlush = true;

stream.Expect(new ExpectAction[] {
new ExpectAction(">", (s)=>{Console.WriteLine("User mode.");
writer.WriteLine("enable");
var r = reader.ReadToEnd();
Thread.Sleep(3000);
writer.WriteLine("secret123" + "\r");
r = reader.ReadToEnd();
writer.Flush();
Thread.Sleep(3000);
writer.WriteLine("term len 0");
writer.WriteLine("sh config");
Console.Write(s);}),

new ExpectAction("#", (s)=>{Console.WriteLine("Enable mode.");
writer.WriteLine("term len 0");
writer.WriteLine("sh config");})
});

//stream.Expect(new ExpectAction[] {
// new ExpectAction("Password:", (s)=>{writer.WriteLine("secret123");
// Thread.Sleep(3000);
// writer.WriteLine("term len 0");
// writer.WriteLine("sh config");
// Console.Write(s);})
//});

//writer.WriteLine(this.HostCommand);

while (counter < 5)
{
Thread.Sleep(1000);
if (stream.DataAvailable)
{
commandResults += reader.ReadToEnd();
Console.Write(commandResults);
}
counter++;
}

//SshCommand cmd = ssh.CreateCommand(this.HostCommand);
//cmd.CommandTimeout = TimeSpan.FromSeconds(10);
//this.commandResults = cmd.Execute();

//SshCommand cmd = ssh.RunCommand(this.HostCommand);
//this.commandResults = cmd.Result;

ssh.Disconnect();
```

Viewing all articles
Browse latest Browse all 1026

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>