Recently there's been lots of changes in my company, and they want to automate things by running scripts. I have a Brocade switch infrastruture with 2 48k and 2 5300's, 2 4900's and 4 4100's.
I need to create a shell script, so that I can remotly SSH in to switch, create zones, upload firmware and do most of the day to day stuff.
I am trying to write scripts but I cannot open SSH session for the swtichs from my unix terminal.
If anyone has done that and can let me know, how to SSH in to FC swtiches from a Shell Script and executes command that would be really apprecaited.
you should be able to simply ssh in like ssh admin@switch.com, the issue is that you need to setup ssh key authentication, otherwise you will be prompted to enter credentials. You need to research if you can setup ssh key based authentication on Brocade.
Hey, I did that. I enable SSH on the switch and then wrote a script and ran it on my linux terminal, but i still cannot connect to swtich. Any ideas??
The script which I worte to test:
#!/bin/bash Server="10.200.11.10" #Switch IP USR="a-rmaddodi" #user name file="zone.txt" # text file the i want to run. (zone.txt has one command in it which is #switchshow) ssh $USR@$Server w > $file
Yes, I can ssh in to the switch with my script and without the script. And I can run all the commands, do zoning and most of the thing if I ssh in to the switch direclty. But the main issue is I cannot run any commands from my script. When I run my script, its lets me log in but my command never runs.
Have anyone tries this or anyone can have a sample script where you can log on to switch via SSH and also executes commands?
Index Port Address Media Speed State Proto ============================================== 0 0 330000 id N8 Online FC F-Port 20:70:00:c0:ff:db:01:d1 1 1 330100 id N8 Online FC F-Port 20:70:00:c0:ff:da:c2:1b 2 2 330200 id N8 Online FC F-Port 24:70:00:c0:ff:da:c2:0f
just some more thoughts on this, especially if you plan on doing this more regularly.
a) Really try ssh key authentication, although I don't know what FOS version you need to get this properly working with several users and keys. The way with directly editing the authorized_keys file on the brocade filesystem with the root account should work though, if it is supported.
b) look at expect[1]. I use pexpect in a python script with a config file where all switches are listed with tags like at which site they are located, type, fabric, ...
so you can conveniently run commands and queries against a specific subset of switches. If you do not use ssh key authentification without a passphrase be careful with the location and read access to the config file as you have to put the password in there.
Because you do not need to manually enter the password you can run some data for reporting via cron at night.
healyj
141 Posts
17918
0
Posted December 12th, 2017 07:00
Hi there,
In our efforts to clean up the forum, we came across your question / statement.
If the question / statement is still valid, not expired and you need an update please reach out again and we try to get it answered.
As for now we will set it to “answered.”
Regards,
Jim