A script and configuration to toggle a VPN server from within Home Assistant. Currently only tested with a router running ASUSMerlin.
Steps:
- Create keys
ssh-keygen -t rsa -b 4096 -C "comment" - Copy key to host
ssh-copy-id user@host - Verfiy the connection
ssh user@host. You shouldn't be asked for a password. - Place vpntoggle.sh and the key somewhere accessable to Home Assistant and make sure the script is executable
chmod +x vpntoggle.sh - Edit the script to match your configuration.
- Add the configuration to you Home Assistant. It's of the type switch.
Things to look out for:
If using docker you will need to generate keys within the container. You can access the container with docker exec -it CONTAINER bash. You will also need to place the script somewhere the containter can find it. I placed mine under the config directory defined in the docker run command.