Perl scripts can be quite helpful for a network administrator, so I went looking for ways to automate a logging and enable myself to perform various commands on 100+ devices.
FIrst I investigated Paramiko, but that enabled me to only issue one command per login, so this does not work.
Then I shifted to Perl, using NET :: SSH2. This works in a wonderful way. I can loop through host files and configure all devices in one go, that is, all MX series routers..
The EX switches do not respond well. I have tried EX2200, EX4200 and EX4500 on two software levels, but neither work. I verified in the logging of the devices and I can see that my script logged in. However, the commands are not accepted. I tried sending the command 'show configuration | save TESTING123', but the messages log only show the successful login.
Is there someone that ran into this same issue and figured it out?
Is there someone using Perl for remote tasks with another piece of software that does work on both MX and EX (and other vendors) so I can look into that?
Re: SSH difference between EX series and MX series
[ Edited ]
I spent a few weeks and wrote my own script to do this using the Net::OpenSSH and Expect modules. Not pretty, and has its quirks, but suits my purposes. A colleague wrote something for getting system backups using the Net::Appliance::Session and Net::Appliance::Phrasebook modules. I didn't know about those modules when I was writing my script, but looking at the modules now they look quite handy.
Then there is the new Puppet for Junos automation that was recently released. Haven't tried it yet since it has code and platform restrictions that we don't currently meet.
I'm attaching my script for you to take a look at as an example. It is being provided as-is, and is NOT supported. It serves my purposes, it may or may not serve yours. Getting it operational is an exercise for the reader. Seriously.
Note that due to OpenSSH's default settings for host key verification, you will need to connect to each device once outside of the script for the host key to get accepted and saved. There may be a way to override that inside the script; I don't know.