04-04-2017 02:15 PM
Hello SAN techies,
Just wanted to know how to script and in what language to script on a Brocade FC switch. I have most codes @ 7.4.1d but i repeatedly keep getting "rbash" error even for a simple command such as 'echo' '>,<' operations. I guess thats a good thing interms of security.
Another observation is you probably need to be logged in as root(cant use admin credentials).
I am tasked with clearing counters on a daily bases and would really like to get this scripted. Let me know if there is any other way
Below are some examples.
sh: nano: command not found
sh: vim: command not found
04-05-2017 01:05 AM
with 7.4.1d security for the admin account was improved and for example bash builtin like for and while was dropped. Redirecting (using < and >) is not supported. So, if you want to run your script on the switch, root account is the only choice left. Another options is to ssh into the switch and send commands to switch. For simple things like clearing counters or where you have a set of switch command you want to run, you can for example (for 6.x or earlier FOS releases you might run into issue with below but for 7.x it works)
ssh admin@my-switch "date; slotstatsclear ;statsclear"
with on login session. Or you can save your command in a file, with one command per line and last command logout (or exit), like
and then run
ssh admin@my-switch < file-name-with command
Next is to use something like expect or similiar to drive the switch, and higher up configuration tools like ansible which do not need an agent on switch. Notice with admin account your limited to the command listed in the command reference manual.
And last, try to avoid running many command via single ssh back to back, e.g. that you ssh into the switch to run command (and exits); then ssh in again directly to run the next commands It is better to have one longer ssh session.
04-07-2017 12:57 PM
04-10-2017 12:18 AM
you are at FOS 7.4.1d where we have a defect for SSH
which you might have run into - workaround is as root
chmod 644 /fabos/users/admin/.ssh/authorized_keys.*
Notice that after "sshutil adduser <username>" and "sshutil importpubkey" you should be able to run ssh with.