Logic Machine Forum
Network Switch Control with SSH - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Network Switch Control with SSH (/showthread.php?tid=5468)



Network Switch Control with SSH - jamesng - 17.06.2024

I'd like to SSH into our Unifi Switches to run a 1 line command to turn on/off a POE connected device. 

While a POE reboot is is possible with the Unifi API, switching a port off for an extenede period of time is not - so SSH seems like a simple solution.  This is the command that need to be executed

Code:
ssh admin@192.168.1.100

<enter password as prompted>

swctrl poe set off id 45

How does one SSH to the switch at 192.168.1.100 from a lua script?

If it helps, one can connect to the Unifi switch with a SSH key instead of a password.

Many thanks in advance 

Kind Regards
James


RE: Network Switch Control with SSH - admin - 17.06.2024

Check this: https://forum.logicmachine.net/showthread.php?tid=176&pid=742#pid742


RE: Network Switch Control with SSH - jamesng - 17.06.2024

Thanks for pointing me at that thread - I generated a key and using io.readproc(run) am now able to send SSH commands to the Unifi switch to control the POE ports.

Kind Regards
James