wfg / docker-openvpn-client

OpenVPN client with killswitch and proxy servers; built on Alpine
MIT License
353 stars 107 forks source link

Allow passing auth file to authenticate with OpenVPN server #28

Closed Toanzzz closed 3 years ago

Toanzzz commented 3 years ago

Summary

This will allow usage with private VPN that required authentication by setting OPENVPN_AUTH_SECRET environment variable. It's value should match the name of the secret (NOT the file used by the secret)

The secret should point to a text file with username & password in separate line, as in the official docs:

--auth-user-pass [up]

Authenticate with server using username/password. upis a file containing username/password on 2 lines (Note: OpenVPN will only read passwords from a file if it has been built with the --enable-password-save configure option, or on Windows by defining ENABLE_PASSWORD_SAVE in config-win32.h).If up is omitted, username/password will be prompted from the console.

Example Usage

services:
  vpn:
    image: ghcr.io/wfg/openvpn-client
    cap_add: [NET_ADMIN]
    devices: [/dev/net/tun]
    environment:
      - HTTP_PROXY=on
      - SOCKS_PROXY=on
      - OPENVPN_AUTH_SECRET=ovpn_auth
    volumes: [~/local/vpn:/data/vpn]
    ports: ["1080:1080", "8080:8080"]
    secrets: [ovpn_auth]

secrets:
  ovpn_auth: { file: ./secrets/auth.txt }

TODO

wfg commented 3 years ago

@Toanzzz thanks, this looks good to me!

It looks like it would work without the OPENVPN_AUTH_SECRET variable, but have you tested it to be sure?

Toanzzz commented 3 years ago

Yes I did test it myself, and it run just fine without that variable.

(Sorry for the late reply)

wfg commented 3 years ago

Awesome! Thanks for the PR.