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");})
});
while (counter < 5)
{
Thread.Sleep(1000);
if (stream.DataAvailable)
{
commandResults += reader.ReadToEnd();
Console.Write(commandResults);
}
counter++;
}
ssh.Disconnect();
```
Comments: ** Comment from web user: drieseng **
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");})
});
while (counter < 5)
{
Thread.Sleep(1000);
if (stream.DataAvailable)
{
commandResults += reader.ReadToEnd();
Console.Write(commandResults);
}
counter++;
}
ssh.Disconnect();
```
Comments: ** Comment from web user: drieseng **
Can you confirm that it's ok to close this issue ?