Zyxel XS1930-12HP SSH command over libssh (C++)

Chris77
Chris77 Posts: 11  Freshman Member
First Comment Friend Collector Fifth Anniversary
edited August 2022 in Switch
Hi,

I am trying to run the SSH command "show pwr" in my program (C++) via SSH connection. I use the libssh for this. I can see in the system log of the switch that the connection works:

"IN authentication: SSH user admin login [IP address = 192.168.0.172]".

When I send the command "show pwr" I receive the "unknown error" (-1). In system log unfortunately nothing is shown here.
If I use a different product instead of Zyxel, everything works fine.
Does anyone have an idea what the problem could be?

All Replies

  • Zyxel_Melen
    Zyxel_Melen Posts: 2,567  Zyxel Employee
    Zyxel Certified Network Engineer Level 1 - Switch Zyxel Certified Network Administrator - Switch Zyxel Certified Network Administrator - Nebula Zyxel Certified Sales Associate
    Hi @Chris77,

    May I know you got the error message when you run your program? Or have you try to SSH to XS1930-12HP and enter the command and get same error message?
    Zyxel Melen


  • Chris77
    Chris77 Posts: 11  Freshman Member
    First Comment Friend Collector Fifth Anniversary
    Hi @Melen,

    in my program, when I send a command, I get an unknown error from the libssh. This only happens with a Zyxel switch. Other switches work fine.
    If I start a session via PuTTY and send the command, everything works.
  • Zyxel_Melen
    Zyxel_Melen Posts: 2,567  Zyxel Employee
    Zyxel Certified Network Engineer Level 1 - Switch Zyxel Certified Network Administrator - Switch Zyxel Certified Network Administrator - Nebula Zyxel Certified Sales Associate
    Hi @Chris77

    Based on your test result, using PuTTY is working fine. And we also tried Tera term and local SSH via Windows command line, they all work well with ZYXEL switch.
    Not sure what Libssh did to cause the difference. Since the error is returned by Libssh, maybe they could explain why it happens.

    Zyxel Melen


  • Chris77
    Chris77 Posts: 11  Freshman Member
    First Comment Friend Collector Fifth Anniversary
    edited June 2022
    Zyxel_Melen,

    The libssh I use runs fine. Several projects run without problems. The problem must be something else. I suspect that the switch only supports "interactive" ssh sessions. If I enter the following command in git-bash:

    ssh admin@192.168.0.10 show pwr
    or
    ssh admin@192.168.0.10 "show pwr"

    I get the following message from the switch:

    "Received disconnect from 192.168.0.10 port 22:2: invalid command pwr."

    To me it looks like the switch does not support the direct commands.

    I found the same problem here in forum:

    Post 1
    Post 2

    Many greetings
    Chris
  • Zyxel_Melen
    Zyxel_Melen Posts: 2,567  Zyxel Employee
    Zyxel Certified Network Engineer Level 1 - Switch Zyxel Certified Network Administrator - Switch Zyxel Certified Network Administrator - Nebula Zyxel Certified Sales Associate
    edited June 2022
    Hi @Chris77

    Zyxel switch currently not support this function.
    We suggest you not to use one line command and build your program step by step.
    You can reference this post to build your program. 
    We also have an idea post which is suggested by other user, I will help to leave your comment there.
    Zyxel Melen