HowTo Run CLI Commands remotely on MLNX-OS

Version 3

    This post shows several methods to run a list of CLI commands to a remote switch.

     

    References

     

    Option 1: Use sshpass command

     

    sshpass allows login in a non-interactive ssh to a remote server.

     

    use the format:

    # sshpass -p <password> <username>@<IP address> cli \"enable\" \"<command1>\"  \"<command2>\" ... \"<command>\"

    For example:

     

    # sshpass -p admin ssh admin@10.7.54.242 cli \"enable\" \"show clock\" \"show version concise\" \"show asic-version\" \"config terminal\" \"ntp server 10.0.8.1\" \"configuration write\" \"show ntp\"

    Time:       22:13:04

    Date:       2015/02/25

    Time zone:  UTC

                (Etc/UTC)

    UTC offset: same as UTC

    SX_PPC_M460EX SX_3.4.0010 2014-11-20 18:47:19 ppc

    ===========================

    SX module           Version

    ===========================

    SX                  9.3.1220

    NTP is administratively enabled.

    Clock is synchronized.  Reference: 10.0.8.1.  Offset: 39.589 ms.

    Active servers and peers:

                                                                       Poll   Last

                    Conf                      Offset  Ref              Interv Resp

    Address         Type Status      Stratum  (msec)  Clock            (sec)  (sec)

    ===============================================================================

    10.0.8.1        serv sys.peer (*)    3    39.589  64.4.10.33         64     64

     

    Option 1: Use SSH with the following format

     

    # ssh admin@<IP address> cli \"enable\" \"<command1>\"  \"<command2>\" ... \"<command>\"

    Note: This option will require a password from the user, unless "no password" was configured on the admin user.

     

    To set the admin to be with no password run on the switch

    switch (config) # username admin nopassword

    switch (config) # configuration write

     

    For example:

    #ssh admin@my-switch-hostname cli \"enable\" \"show clock\" \"show version concise\" \"show asic-version\" \"config terminal\" \"ntp server 10.0.8.1\" \"configuration write\" \"show ntp\"

     

    Mellanox MLNX-OS Switch Management

     

    Time:       21:46:04

    Date:       2015/02/25

    Time zone:  UTC

                (Etc/UTC)

    UTC offset: same as UTC

    SX_PPC_M460EX SX_3.4.0010 2014-11-20 18:47:19 ppc

    ===========================

    SX module           Version

    ===========================

    SX                  9.3.1220

    NTP is administratively enabled.

    Clock is unsynchronized.

    Active servers and peers:

                                                                       Poll   Last

                    Conf                      Offset  Ref              Interv Resp

    Address         Type Status      Stratum  (msec)  Clock            (sec)  (sec)

    ===============================================================================

    10.0.8.1        serv pending         3    -5.809  64.4.10.33         64     59