Reset POE Port on Unifi Switch - Connecting to a device via SSH Key - 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: Reset POE Port on Unifi Switch - Connecting to a device via SSH Key (/showthread.php?tid=3139) |
Reset POE Port on Unifi Switch - Connecting to a device via SSH Key - jamesng - 02.02.2021 Hi I'd like to automate the power cycle of a POE port on a Unifi Switch. The Unifi docs say this can be achieved by connecting to the device via a SSH key and then issuing some telnet commands. I can run these commands ok from the terminal window of my desktop, however am not to sure how to initial a ssh connection from logic machine / CBUS SHAC. Here the sequence of commands that run ok from my desktop Mac to power cycle port 15. Code: ssh -i /Users/james/.ssh/id_rsa admin@192.168.1.100# Here's the beginnings of my LM script to issue the telnet commands. Can anyone advise how to modify the script to SSH to the switch with an SSH key (the key is in the id_rsa file in the above example) Code: function resetPOESwitchPort(switchport) Any advice would be greatly appreciated Kind Regards James RE: Reset POE Port on Unifi Switch - Connecting to a device via SSH Key - admin - 02.02.2021 Which switch model do you have? At least some should have a web interface which you access from scripts. This is much easier than SSH. RE: Reset POE Port on Unifi Switch - Connecting to a device via SSH Key - Seijboldt - 02.02.2021 Have a look at this unifi API: https://ubntwiki.com/products/software/unifi-controller/api Posting to the endpoint `api/s/{site}/cmd/<manager>` with the `json {"cmd": "command"}` you can invoke commands on the controller. Power cycle poe port: devmgr power-cycle mac = switch mac ( required ), port_idx = PoE port to cycle ( required ) RE: Reset POE Port on Unifi Switch - Connecting to a device via SSH Key - admin - 02.02.2021 See this topic for an example that you can use: https://forum.logicmachine.net/showthread.php?tid=2450 RE: Reset POE Port on Unifi Switch - Connecting to a device via SSH Key - jamesng - 03.02.2021 Hi I'm attempting to control Unifi US-48-500W and US-8-60W switches (all running the latest firmware - cloud key firmware 2.0.27 which changes the access url from https://controllerip:8443 to https://controllerip/network/site) and I think breaks the reverse engineered API. I was under the impression that the API (https://ubntwiki.com/products/software/unifi-controller/api) was a reverse engineered project and that the telnet control which was officially supported by Unifi. Is there an example of how to make the SSH connection and execute the telnet commands with Logic Machine? Kind Regards James RE: Reset POE Port on Unifi Switch - Connecting to a device via SSH Key - benanderson_475 - 03.02.2021 (03.02.2021, 02:43)jamesng Wrote: Hi Hi jamesng, from the last unifi update 2 things have changed, 1- controller access is no longer avalible on port 8443, this is now https on port 443 and 2- end points have changed for login endpoint api/auth/login and for api endpoint prefix with /proxy/network see below code , change to suit your requirements Code: htps = require("ssl.https") |