VMware Cloud Community
sbeaver
Leadership
Leadership

Using the SSH plug-in to configure a Cisco device

Hey has anyone figured out a way to use the SSH plug-in to configure a Cisco device with multiple commands starting with config t?  From what I can see when a command is executed the execution channel is closed and multiple commands does not work.  I believe a stream has to be established for this to work and I am struggling to create that stream native in vRO and the plugin.  Single commands and queries work great it is just the chain of multiple commands that is not

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos
5 Replies
iiliev
VMware Employee
VMware Employee

Try if something like the following code to execute multiple commands in a single session will work:

var session = new SSHSession("10.23.34.45", "myusername"); 

session.connectWithPassword("mypassword"); 

 

session.executeCommand("echo 'start'", true); 

session.executeCommand("ls -l /root", true); 

session.executeCommand("ls -l /etc", true); 

session.executeCommand("echo 'done'", true); 

 

session.disconnect(); 

If it doesn't work, is it an option to put all your commands in a single script, upload the script on your host, and then run it?

Reply
0 Kudos
sbeaver
Leadership
Leadership

Ilian,

That works well running standard ssh sessions but things are a little different with the CISCO devices.  The SSH plugin opens the session, opens an execution channel, issues the command and closes the execution channel but leaves the session open if you do not disconnect.  The CISCO devices are expecting the execution channel to stay open and that is why it is not accepting multiple commands at a time.  Kinda like creating an SSH stream in powershell.  I have this working in powershell but I am trying to keep things inside of vRO without having to proxy out to other system first.

Thank you for responding and sharing what you have

Cheers

Steve

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos
jarviswmark
Contributor
Contributor

Hi,

Did you find away to configure a cisco switch from vRO?

Kind regards

Mark

Reply
0 Kudos
jarushepic
Enthusiast
Enthusiast

We do this to issue commands to Cisco MDS switches

<code>

zoneset name zoneset3 vsasn 3 ; member my_new_zone_1 ; member my_new_ozne_2

<code>

using the NXAPI, which basically takes an SSH command, so you can probably just send a semi-colon delimited string to the ssh session.

Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast

I've used expect scripting and an expect host to configure Cisco devices before.

You need to generate the expect script on the vRO side, pass the script to an expect host ( using something like GuestOPS), then execute the expect script against the Cisco device.

This doesnt easily pull cisco configs, but changes them well.

Reply
0 Kudos