Command line switch to reset Unifi VPN

Hi,

For some reason, I need to reset my VPN connection to my USG pro 4 quite often. I believe that this is due to UDP.

I have tried to create a Command line switch to reset this, but I cannot seem to get it to work

  - platform: command_line
    switches:
      reboot_vpn:
        command_on: "ssh -i /ssl/ubntPriv [email protected] 'restart vpn'"
        command_off: "ssh -i /ssl/ubntPriv [email protected] 'restart vpn'"

I created an ssh certificate (ubntPriv) and placed it in /ssl

Can anyone help at all with this?

The error I get in the log is:

## Log Details (ERROR)

Wed Jun 05 2019 08:54:10 GMT+0100 (British Summer Time)

Command failed: ssh -i /ssl/ubntPriv [email protected] 'restart vpn

Maybe check this solution that works for turning on/off the Guest Network:

You may also try to put your SSH command into a .sh script and call that from the command line. In the past i made the experience that this works while the direct command sometimes does not work.

There is an API available that you could explore to see if restarting the USG is an option.

This is a good resource for exploring the API: https://github.com/Art-of-WiFi/UniFi-API-browser

You might also check this link: http://onetimeblog6.blogspot.com/2015/03/how-to-restart-devices-on-unifi.html