SSH comand FROM OpenHab to another device (not into OH ;)

  • Platform information:
    • openHAB version: 4.0.1

As long as I was able so search I could only find Topics about how to connet to OH. (Thats OK)

But I have the challange to get some status information of my router (that has no REST-API) but supports cli over ssh and telnet.

So once connected I can do:

> ip arp status -v 3

[ARP Table]
 Index IP Address     MAC Address         HOST ID                 Interface  VLAN   Port
   1   192.168.3.11   D4-38-9C-5F-E1-14                            LAN3       VLAN3   P2

What would be brilliant to use, because my VLAN3 is for guests only :wink:

So can anyone give me a hint or even an easy example which binding I can use for and how it would be manageable to handle the response? (String inside Item would be enough, then I could parse it by myself in a script)

Thanks and enjoy the last Month of the Year!

You could use “executeCommandLine” to start “ssh” and “ssh” should send the command “ip arp status -v 3” to your router. “executeCommandLine” should return the result of the command “ip arp status -v 3”.

You could write a shell script and put it into openHAB’s exec-Folder. In the shell script you can send whatever command to your router and process the result with whatever tool you like. In the end your shell script returns a value or a list of values which you can process inside the rule engine.

As @Jogobo indicates, you’ll need to use the executeCommandLine action or the Exec binding. You will probably want to create a shell script for this.

For safety you’ll probably want to have certificate based authentication configured for the openhab user so it can ssh without entering a password.