Run OpenVPN Access Server in Docker 🌱

What is OpenVPN Access Server?

OpenVPN Access Server, [a] self-hosted VPN solution, simplifies the rapid deployment of a secure remote access and site-to-site solution with a web-based administration interface and built-in OpenVPN Connect app distribution with bundled connection profiles. -https://openvpn.net/access-server/

Installing Docker

  1. Log into the Linux based device
  2. Run the following commands in the terminal
    # install prerequisites
    sudo apt install apt-transport-https ca-certificates git curl software-properties-common gnupg-agent -y
    # add docker gpg key
    curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
    # add docker software repository
    sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
    # install docker
    sudo apt install docker-ce docker-compose containerd.io -y
    # enable and start docker service
    sudo systemctl enable docker && sudo systemctl start docker
    # add the current user to the docker group
    sudo usermod -aG docker $USER
    # reauthenticate for the new group membership to take effect
    su - $USER

Running OpenVPN Access Server

  1. Now that Docker is installed, run the following commands to setup the OpenVPN Access Server Docker container and run it
    # create working directory
    mkdir ~/docker/openvpn-as -p
    # run openvpn access server container
    docker run -d --name openvpn-as --cap-add=NET_ADMIN -p 943:943 -p 8443:443 -p 1194:1194/udp -v ~/docker/openvpn-as:/openvpn openvpn/openvpn-as
    # find the temporary password
    docker logs openvpn-as | grep 'Auto-generated pass'
  2. Locate the line Auto-generated pass = and copy the password to your clipboard
  3. Open a web browser and navigate to https://DNSorIP:943/admin
  4. Login with the username openvpn and the Auto-generated password located earlier
  5. Click the Agree button to accept the EULA
  6. Click User Management > User Permissions in the left navigation
  7. Click the edit icon next to the openvpn user
  8. Enter a new password in the Password field > Click the Save Settings button
  9. Click Logout at the bottom of the left navigation
  10. Log back in with the username openvpn and the updated password
  11. Welcome to OpenVPN Access Server running in Docker

Source: https://openvpn.net/as-docs/docker.html