Disable/Enable WIFI using external script

Hi there!

I have not been using OpenWRT for quite some years now, as my current AC2600 router does not support it. (My previous router actually did, but was way to slow for my 600mbps symmetrical glassfiber connection)

But here's what it's about:

I have managed to update my TP-Link RE200v2 device today using the latest OpenWRT firmware.

This RE200 has now successfully been set up as an access point, the ethernet cable is linked to my main router and the wifi connections are used "upstairs" for a better connections because of the blocking reinforced concrete floors in between..

But during the nighttime I want to disable the WIFI using a script running on my Synology NAS (linux), the same way I managed to do this for my AC2600 router, which is the actual WLAN/LAN router.

So I actually do not want to use the cron tab, but somehow drive it externally, which I assumably should be able to do since the NAS is wired to the same network as the RE200.

BTW: SSH or curl commands are not mandatory, anything I can put in the batch script on my NAS to turn WIFI on and off on the RE200 will do.

Any help is much appreciated,

Hans

wifi up/ wifi down over ssh using ssh keys.

Yes, this works. Unfortunately I am not able to use sshpass nor the "expect" command wich rules out using SSH from my script :s

I have also been fiddling with keypairs (using ssh-keygen) to allow login without a pass, but didnt get it to work (yet). ssh-copy-id is missing so I tried several other commands to upload the key, but to no avail.

A potential alternative solution: Isnt there an REST-API call that I can in order to enable/disable WIFI? Or maybe by some curl command?

For now I managed to change the crontab to do what I want, but I would rather drive it all fromone place (my nas also enables/disables wifi on my "main" router at programmed times)

Regards - Hans

cat ~/.ssh/id_rsa.pub | ssh root@openwrt.lan 'cat >> /etc/dropbear/authorized_keys'

You could also upload the NAS' public key to the router using LuCI.
System>Administration>SSH-Keys

2 Likes

Yes, that statement copied the key. What was still failing though is that on the NAS I had to change the access rights to the id_rsa file like so:
chmod 400 <homedir>/.ssh/id_rsa
because ssh complained the file was too open.
Now it works like a charm! Thx!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.