gs1920-24hpv2 non-interactive ssh `invalid command`

R4scal Posts: 2
edited April 2021 in Switch


  1. when i logged in ssh session and execute `show system-information` - all works fine
  2. when i execute `ssh [email protected] show system-information` - Received disconnect from port 22:2: invalid command system-information.

Is there any way to make this work?

All Replies

  • Zyxel小編 Lucious
    Zyxel小編 Lucious Posts: 279  Zyxel Employee

    Hi @R4scal

    Zyxel switch currently doesn't support such command to directly ask the info.

    It seems to us that your goal is to poll data from devices, our suggestion would be to use SNMP or create a script.


  • @Zyxel_Lucious Thanks for answer

    Any plans to add support of directly ask the info? It's really needed, because snmp doesn't have enough metrics about environment and poe ports

  • Zyxel小編 Lucious
    Zyxel小編 Lucious Posts: 279  Zyxel Employee
    edited November 2019

    Hi @R4scal

    There is no plan for this feature due to internal concern which involves security breach.

    For now, a script SSH is rather recommended for your demand.


  • Time for forum thread necromancy..

    I came across this problem, tried many methods to get around it. This one just about works but is unreliable. It looks like the switch might terminate the connection after the command has run but before all the command output has been sent over the SSH session.

    echo -e "show interfaces status\nshow version\n" | sshpass -p 'routerpasswordhere' ssh -v [email protected]
    Eventually I've found a reliable method is using the linux utility "expect". Here is a very simple example file. Make the file then chmod to +x and then run it. (obviously make sure you've installed expect (e.g. apt install expect).)

    #!/usr/bin/expect -f
    set username [lindex $argv 0];
    set ip [lindex $argv 1];
    spawn ssh [email protected]$ip
    expect "password: "
    expect "# "
    send "show version\r"
    expect "# "
    send "show interfaces status\r"
    expect "# "
    send "show mac address-table all\r"
    expect "# "
    send "exit\r"

    I then call the script using ./switch_info_fetcher techsupport
    I hope the above advice helps someone else searching for the answers.