Skip to content
Advertisement

Issue connecting to cisco ios switch with custom menu enabled

I am trying to connect to a Cisco [Cisco IOS Software, C2900 Software (C2900-UNIVERSALK9-M), Version 15.4(3)M3] switch via ansible/python. But I am facing issue because we have enabled a menu when we connect to vty.

Is there any working sample someone can point me towards where I could pass thru this menu and run commands as usual?

JavaScript

Thanks

Advertisement

Answer

You should use expect, or the pexpect python implementation.

A sample workflow:

  • open a connection and look for a specific string (ie: “Banner), when found send “X” for the exec prompt
  • read the output and look for a string followed by “>”, then send “enable”
  • read the output and look for a “Password” prompt, then send “somepassword”
  • read the output and look for a string followed by “#”, then send “some command” and so on.
Advertisement