Sometimes username and password authentication is needed when connecting to openvpn server. There are plenty of plugins written in python, php, ruby, ... Nevertheless, this one is written perl and uses htpasswd format file as a database.
Only perl and libapache-htpasswd-perl are required.
- Copy the script somewhere (I personally suggest /usr/lib/openvpn).
- Update your openvpn config
auth-user-pass-verify "/usr/lib/openvpn/openvpn-auth-file.pl /etc/openvpn/passwd" via-env
script-security 3
client-cert-not-required
username-as-common-name
- Generate your username and password (you can use this site https://www.htaccesstools.com/htpasswd-generator/) and put it to /etc/openvpn/passwd
- Restart openvpn
This script has been tested on currently stable Debian (wheezy).