Skip to content

vtwebguy/homeassistant-openvpn-client

 
 

Repository files navigation

Home Assistant OpenVPN Client Add-On

This is an Add-On for Home Assistant that enables your Home Assistant server to tunnel its communication with the world through a secure OpenVPN connection. It is especially useful for users who want to integrate Google Home, Amazon Alexa, or other cloud services with Home Assistant, but do not want to expose their server directly to the internet.

Features

  • Provides a web interface (Flask-based) for uploading VPN configuration files.
  • Supports two configuration methods:
    • Upload a single .ovpn file containing all OpenVPN client configuration and certificates.
    • Upload individual certificate and key files (ca.crt, client.crt, client.key, ta.key).
  • Automatically starts OpenVPN using the uploaded .ovpn file, or generates one from Home Assistant options if not provided.
  • Designed to run as a Home Assistant add-on in a Docker container.

How it Works

  1. Upload Configuration:
    • Access the web UI at http://<server>:8090 (or via the Home Assistant sidebar if you use panel_iframe).
    • You can upload either:
      • A single .ovpn file (recommended, as it contains all necessary configuration and certificates), or
      • All required certificate/key files individually (ca.crt, client.crt, client.key, and optionally ta.key).
  2. OpenVPN Startup:
    • If a .ovpn file is uploaded, it is used directly to start the OpenVPN client.
    • If not, the add-on will attempt to generate a configuration from Home Assistant options (if configured).
    • The add-on waits for the necessary files before starting the VPN connection.

Installation

  1. Build and Install the Add-On:

    • SSH into your Home Assistant server:
      ssh <user>@<server>
    • Clone this repository into your /addons directory:
      cd /addons && git clone https://github.com/larsklitzke/homeassistant-openvpn-client.git
  2. Enable the Web UI in Home Assistant:

    • Add the following to your configuration.yaml:
      panel_iframe:
        openvpn:
          title: OpenVPN
          icon: mdi:cloud-check
          url: http://<server>:8090
    • Replace <server> with the address of your Home Assistant server.
  3. Restart Home Assistant:

    • After restarting, you can access the add-on from the Home Assistant add-on page. There, you can view the add-on's configuration, README, and logs.
    • If you have set up the panel_iframe as described above, you may see an "OpenVPN" panel in the sidebar for direct access to the web UI. (Note: In some Home Assistant installations, the panel may not appear automatically. You can always access the web UI directly at http://<server>:8090.)
  4. Upload VPN Configuration:

    • Open the OpenVPN web UI by visiting http://<server>:8090 in your browser (or use the sidebar panel if configured).
    • Upload either a .ovpn file or all required certificate/key files as described above.
  5. VPN Connection:

    • The add-on will automatically start the OpenVPN client using your uploaded configuration.

Notes

  • If you upload a .ovpn file, it will be used directly. If you upload individual files, ensure your Home Assistant options are configured to generate a valid OpenVPN config.
  • The web UI supports both upload methods and provides feedback on upload success.
  • The add-on will not overwrite an uploaded .ovpn file.
  • Configuration Persistence: To ensure your VPN configuration persists across Home Assistant or container reboots, place your client.ovpn file in the /share/ directory. On startup, the add-on will copy /share/client.ovpn to /data/client.ovpn if no configuration is present. This is useful for automated deployments or when you want to avoid re-uploading the configuration after every restart.

License & Credits

The initial version of the Dockerfile to install the OpenVPN client was created by TheSkorm. This fork of the add-on by larsklitzke that built on that work and added a web interface and Home Assistant integration now provides support for OpenVPN .ovpn configuration files.

About

OpenVPN client Add-On for Home Assistant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 59.0%
  • Shell 21.8%
  • Python 15.7%
  • Dockerfile 3.2%
  • Ruby 0.3%