Fibre Channel (SAN)

Reply
Occasional Contributor
Posts: 12
Registered: ‎10-31-2014

scripting in Brocade switches

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.

nano 1.txt
sh: nano: command not found

 

vim 1.txt
sh: vim: command not found

 

cheers

Brocade Moderator
Posts: 233
Registered: ‎03-29-2011

Re: scripting in Brocade switches

Hi,

 

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

 

date

slotstatsclear

statsclear

exit

 

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.




If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution".

Any and all information provided by me is not reviewed, approved or endorsed by Brocade and is provided solely as a convenience for Brocade customers. All systems and all networks are different and unique. If you have a service affecting network problem, please open a TAC service request for service through Brocade, or through your OEM equipment provider. If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution"
Occasional Contributor
Posts: 12
Registered: ‎10-31-2014

Re: scripting in Brocade switches

Martin,
Thanks for your response. Here's my problem

ssh admin@10.x.x.x "date"
admin@10.x.x.x's password:
Fri Apr 7 23:03:04 GMT 2017

i do not want a password prompt everytime i have to execute a command. I tried to exchange rsa keys to avoid the prompt but i keep getting rbash restriction error.
Brocade Moderator
Posts: 233
Registered: ‎03-29-2011

Re: scripting in Brocade switches

Hi,

 

you are at FOS 7.4.1d where we have a defect for SSH

 

defect in ssh 741d

 

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. 




If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution".

Any and all information provided by me is not reviewed, approved or endorsed by Brocade and is provided solely as a convenience for Brocade customers. All systems and all networks are different and unique. If you have a service affecting network problem, please open a TAC service request for service through Brocade, or through your OEM equipment provider. If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution"

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.