Here is my take how to remotely activate commands on your router. I am using an R7000 running an Asuswrt firmware. There are probably other ways to achieve this. Maybe if some can take the below have it integrated in the current Asuswrt component.
I’m running HA on my RPI3, You need to generate and copy the ssh key to the router. This to execute the command without using yr router password.
**ssh in your server to generate private keys: **
- generate ssh key
command: ssh-keygen and typ 3 times for default answers
- send keys to your router and use yr router password:
ssh-copy-id -p xxx [email protected] [use your own user ID, default is admin if you did not change it]
Create scripts and make them executable chmod u+x scriptname.sh
You can also add VPN Server nr 2 (vpnserver 2) or add up to 5 VPN Client as well
for client you can adapt the script above as follows: service start_vpnclient1
Something like this for turning guest networks on/off might be handy. Combine that with a Bluetooth sensor and have guest network turn on/off automatically when friends/family come around to visit.
I have not tested the code below but you could try this on the router itself in terminal and if it works you can then adapt the code in the first post above.
enable_guest_network.sh should contain something like:
Hi, can I ask, I am using Hassio, and where do I host the vpn_server1_on.sh etc?
Also, when I try manually ssh -p ‘xxx’ ‘user@domain’ service start_vpnserver1 , it returns
I dont use hassio, I guess should create a folder in your hass config ie. scripts and whitelist it.
First try to ssh to your router directly and execute the command and check in the Aswrt VPN tab that the VPN 1 stopped and started, as per screenshot below.
service stop_vpnserver1
service start_vpnserver1
Secondly, did you follow the steps in the guide regarding copying the keys from hassio to your router with ssh-copy-id ?
Sorry to be such a noob, do you have any tutorials how to add these controls (i.e. the VPN client) to home assistant UI? I am very new to home assistant, I have it up and running in docker but do no know where to put your script. If you could point me to a tutorial that would be so helpful.
Thanks so much for developing this script it will be so very helpful if I can get it working!