Docker-openvpn: The file '/etc/openvpn/vars' was not found

Created on 26 Sep 2020  路  20Comments  路  Source: kylemanna/docker-openvpn

Looks like kylemanna/openvpn:latest is broken. Also kylemanna/openvpn:2.3 works fine.

$ docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn ovpn_initpki

Easy-RSA error:

The file '/etc/openvpn/vars' was not found.

Most helpful comment

All 20 comments

Same thing happened to me.

for the dummies like me

docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm kylemanna/openvpn:2.3 ovpn_genconfig -u udp://vpn.yourdomain.com
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn:2.3 ovpn_initpki

Also kylemanna/openvpn:2.3 works fine.

The issue is about kylemanna/openvpn:latest

The same also happing to me, will try @joeky888 reference

using 2.3 works

hmmm, I can get the image running by using the 2.3 tag, but upon trying to create a client:

Easy-RSA error:

EASYRSA_PKI does not exist (perhaps you need to run init-pki)?
Expected to find the EASYRSA_PKI at: /etc/openvpn/pki
Run easyrsa without commands for usage and command help.
failed to resize tty, using default size
/usr/local/bin/ovpn_getclient: line 16: /etc/openvpn/ovpn_env.sh: No such file or directory

@kylemanna hi, i've been using the 2.4 tag from dockerhub for months now without any problem. I see now that you overwrote the 2.4 tag on dockerhub just 14 days ago. Are you aware of the problem described in this thread?

@ebarault I'm not aware of what the problem remaining is. I fixed a number of issues most importantly the CI tests running on Tavis-CI. No issues are reported on the branch that docker tag points to:

https://travis-ci.org/github/kylemanna/docker-openvpn/builds/741565318

Does the problem remain? Can you show me details like docker image hash + error?

Pretty sure this is fixed, someone can let me know if it's not true. CI builds pass and they'd fail on this if it was a problem.

Hi Kyle,

Thanks a lot for the hard work on this project.

I was finding a similar issue with a fork of your repo, but it seems to be an issue with EasyRSA, not any of your binaries.

It's fixable by running the easyrsa_export binary, pointing to /etc/openvpn/vars. Then, init_pki will work fine:

bash /usr/local/bin/easyrsa_vars export > /etc/openvpn/vars
bash /usr/local/bin/ovpn_initpki

Picked up from references below:

StackOverflow
..and its related article
easyrsa_vars script


Hopefully this should point people having the same issue towards the right direction. I haven't inspected your code yet to see if this is referenced anywhere and if it's skipped somehow.

Cheers!

I understand this was an issue, but I've updated many thing to resolve things like this. Can anyone show me the exact steps to reproduce this on any Docker Hub hosted image (must include hash of image)?

The Travis-CI builds work fine with new images and I'm convinced this problem was resolved sometime ago until someone can show me more.

Hi @kylemanna
with image 4fa457dfce43
image
I had to use this trick
touch /etc/openvpn/vars
https://github.com/ebarault/ovenvpn-ansible-role/commit/e6b221329632720bb0c0fb9f9547d8cf8b56b4ad#diff-3d0ff1709ca48add100327bb2a468e6c508fb92a159c64c4f99ad1df89d9bddeR82

@ebarault I don't see anything like that. Here's my console:

$ docker volume rm $OVPN_DATA
ovpn-data-example

$ docker pull kylemanna/openvpn:2.4

2.4: Pulling from kylemanna/openvpn
Digest: sha256:7586e816602b14bb00553816d09c6890891a6d7d62a446352cdba1c4c37456dc
Status: Image is up to date for kylemanna/openvpn:2.4
docker.io/kylemanna/openvpn:2.4

$ docker inspect kylemanna/openvpn:2.4 | jq '.[0].Id'
"sha256:4fa457dfce432adb384a04f268cd4b9b73b5d1f660e857a114a2505bbd71ef6e"

$ docker volume create --name $OVPN_DATA
ovpn-data-example

$ docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn:2.4 ovpn_genconfig -u udp://VPN.SERVERNAME.COM
Processing PUSH Config: 'block-outside-dns'
Processing Route Config: '192.168.254.0/24'
Processing PUSH Config: 'dhcp-option DNS 8.8.8.8'
Processing PUSH Config: 'dhcp-option DNS 8.8.4.4'
Processing PUSH Config: 'comp-lzo no'
Successfully generated config
Cleaning up before Exit ...

$ docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn:2.4 ovpn_initpki nopass
Note: using Easy-RSA configuration from: /etc/openvpn/vars

init-pki complete; you may now create a CA or requests.
Your newly created PKI dir is: /etc/openvpn/pki

Note: using Easy-RSA configuration from: /etc/openvpn/vars
Using SSL: openssl OpenSSL 1.1.1g  21 Apr 2020
Generating RSA private key, 2048 bit long modulus (2 primes)
...............................................................................+++++
.............................+++++
e is 65537 (0x010001)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:

CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
/etc/openvpn/pki/ca.crt

Note: using Easy-RSA configuration from: /etc/openvpn/vars
Using SSL: openssl OpenSSL 1.1.1g  21 Apr 2020
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
.............................+...............+.............................................................................................................................................................................................+....................................................................................................+....................................+...........+.........................+.....................................................................................................................................................+.........+.......................................................................................................................................+.......................+............................................................................+.......................................................................+.......................+.......+............................................................................................................................................................................................................................................+....................................................................................................................+.....................................................................................................................................................................................................................................+..........................+............................+................................+...........................................................................................................................................................+...........................................................+........................+.........+........................................................................................................................................................................................................+......................................................................................................................................................................................................+.................................................................+.............................................+........................+..........................................................................................................................+.....+.........................................................+................................................+................................................................................+............................................................................................................................................................................................................................................+............................+........................................................+............................+...........+.........................+................................................+....................+........................................................................................................................+......................................+..............................................+...................................+...........................................................+........................................+.....+...................................+...............+..+...................................................................................................................................................................................+.............................+.....................................................................+.............................................................................................+...................................................................................................................................................................................................................+............................................+.....................................................................+..+......................+..................................................................................................................................+.....................................................................................................................................................................................................................................................................+.....+........................................................+..............................................................................................................................................................+......................................................................................+....................................................................................................................................................+.........................................................+......................................................................................................................................................................................................................................................................................................................................................................................................................+....+.............................................................................................................+.....................................................................................................................................................................+............................................................................................+...............................................................................................................................................................................+.................+............................................................................................................................................................................................................................+....................................................................................................................+..................................................................+...........................................................................................................................................................................................................+............................+...+........................................................................+..................................................................+..............................................+...........................................................................................+...................................................................................................................................+...............................................................................................................................................................................+........................................................................................................................................................+....+........................................................................+...................................................................................................................................................+..........................................................................................................................................................................................................................................................................................+....................................................................................................................................+..................................+....................................................................................................................................................................................................................................................................................................................................................................+..............................................................................................................................................+...............................................................................................+.......................................................................................................................................................................................+......+..................................................+...........................................................................................................................................................+................................................................................................................................................................................+..............................................................................................................................................+..................+..............................................................+.........................................................+......+.........+...............................................................................................+.........+.............................................................................................+................................................+......................................................................................................................+..........................................+................................................................................................................................+...........+..........................................................................................................+.........................+..............................................................................................................+................................................................................................................................................+........................+..................................+.........+..............................................................+..............+..........................................................................................................................................................+.......................................+........................................................+...................................................................................................................................................................................................................................+.................................................................................................+.........................................................................................................................................................................................................................................................+............................+..................................................+...............................................+..............................................................................................................................+...................................................................................................+......+........................................................................................................................................+.....................................................................+..............................................+..................................................................................................................................................................................................................+.............................................................................................................................+................................................................+...........................................................................................................................................+................................+.........................................................................................................................................................................................................................................................................................................................................................+...........+......................................+.........................................................................................+..............................................................................................................................................................................................................................................................................................................................................................................................................+....................................................................+......................................................................................+.......................................................................................................+................+.......+..+................................................................................+.........................................................+..........+.....+........................................+.........................................................................................................................................................................................................................................+...............................................................................................................................................................+.............................+................................................+...................................................................+..+.......+..............................................................+..................................................................+.....................+.........+............+.....................................................................................................+.........+........................................................................+.............+.....................................................................................+..................................................................+................................+..........................................................+...................................................................................................................................................................................................................+........................................................................................................................................+...........................................................................................................................................................+......................+..........................................................................+............................................................................+...............................................................................................................................................................................................................................................................................................+.....................................................................................................................................+.+........................................................+.........................+..............................................+......................+...........................................................+...............+...............................................................................+..................................................+.................................................................................+............................................................................................+....+...........................................................................................................+...+........................................................................................+...............................................+...+.......+...........................................................................+...................................................+.................................+...........................................+........................+..............................+..........................................................................................................................................................................................................................................................................................................................................................................................................+..+............+............................................+..................+...............................................................................................................+.......................................................................................................................................................................+.....................................................+...................................+......................................................................................................................................................................................+...................................+...............................................................................................................................................................................................+..+..............................................................................................+...+.........................................................................................+.....................................................................................................................+............................................+.......+..+.............................................................................................+..........................................................................................................................................................+..........+.............+.......................................................................................................................................................................................+....+.................................................................................+.........................................................................................................................................................................................+................................+..................+..................................................................+...............................+...............................................................+......................+..............+...................+.................................................................+..........................................................................................................................+.............................................................................................................................................................+......................................................................................................................+..............................................................+.......................................................................+........+..................+........................+...................................................+....................................................................................................+.+.......................................................................................................+.....................+............................................................+......+..................................................+..................................................+..........................................+...........................................................+.............................................................................................................................................................................................................................................................................................................................+..........................................................................+.......................................................................................................................+............................................................................................+................................................................................................................................................................................+.................................................................................+.......................................................................................................................................................................................................................................................................+......................................................................................................................................................................................................................................................................................................................................................+..................................+............................................................................................................................................................................................................................................................................................................................................+................................................................................................................................................................................................................+............................................................................................................................................+.....................................................................................................................................+....................................................................+.....................................+............+..............................................................................................................................................+...............................................................................+..................+.........................+........................+...................................+.....................................+...........+.................................+....................................................................................................................................................+.......................+......+....................................+........................................+..............................................................................................+........+......................................+...........................................................................................+...........................................+.........................................................................................................................................+............................................................................................................................................................................................................................................+.......................+......................................................................................+..............................................................................+.............+............................................................................................+..................................................................................+.................................................................................................................................+.......................................................................+....................................................................+...........................................+..................................................................................................................................................................................................................................................................................................................................................+.............................................................................+...........+..................................+.............................................................................................................................+.......................................................+..............................+..........................................................................................................+......................................................................................+..+....................................................................................................................................................................+.............................................................+...............................................................................................................................................................................+.................................................................................................................................................................................................+...................................................................................................................................................................................................................................................................................+..................................................................................................+.............................................................................+...........................+..................................................................................................................................................+............................+......+....................................................................................................................................................+.........+.................................................................................................................................................................................................................................................................................................................................................................................................................................................................+...........................................................................................................................................+............................................................................+..............+..............................................................................................+.....................+........................................................................................................................................................................+..........+.................................................................................................................................................................++*++*++*++*

DH parameters of size 2048 created at /etc/openvpn/pki/dh.pem

Note: using Easy-RSA configuration from: /etc/openvpn/vars
Using SSL: openssl OpenSSL 1.1.1g  21 Apr 2020
Generating a RSA private key
.................................................+++++
.............................................................+++++
writing new private key to '/etc/openvpn/pki/easy-rsa-68.GmDdej/tmp.cmbeMk'
-----
Using configuration from /etc/openvpn/pki/easy-rsa-68.GmDdej/tmp.KemKCF
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName            :ASN.1 12:'VPN.SERVERNAME.COM'
Certificate is to be certified until Mar  6 07:36:25 2023 GMT (825 days)

Write out database with 1 new entries
Data Base Updated
Note: using Easy-RSA configuration from: /etc/openvpn/vars
Using SSL: openssl OpenSSL 1.1.1g  21 Apr 2020
Using configuration from /etc/openvpn/pki/easy-rsa-144.nagFbj/tmp.pCKmnb

An updated CRL has been created.
CRL file: /etc/openvpn/pki/crl.pem

Why is this issue closed? Just checked back, the problem is still there.

@kylemanna here are the images loaded on my computer:
image

Here are their hashes:
image

veeveisb@veeveisb-OptiPlex-7010:~/Desktop$ docker inspect kylemanna/openvpn:latest | jq '.[0].Id'
"sha256:d5a2586f86e0d3aff02efc8abc147a1e784c5ef7a8b8a0940ba03faa0d11b6fa"
veeveisb@veeveisb-OptiPlex-7010:~/Desktop$ docker inspect kylemanna/openvpn:2.4 | jq '.[0].Id'
"sha256:4fa457dfce432adb384a04f268cd4b9b73b5d1f660e857a114a2505bbd71ef6e"
veeveisb@veeveisb-OptiPlex-7010:~/Desktop$ docker inspect kylemanna/openvpn:2.3 | jq '.[0].Id'
"sha256:f0a0813c5240026ec823d5aab4393f4674cac553fe1f2a7004e8b3dc4bf1ad01"

Following are the results of creating a client using different image tags:

  • with kylemanna/openvpn:latest

image

  • with kylemanna/openvpn:2.4

image

  • with kylemanna/openvpn:2.3

image

As you can see only the image with the tag 2.3 passes successfully the rest fail.

@RafayAK thanks for sharing, now I understand what's going wrong.

Can you build the dev image and test it?

$ git fetch origin
$ git checkout origin/dev
$ docker build -t openvpn-test .

Then run the same command replacing kylemanna/openpvn:2.4 with openvpn-test and share your result. Once I hear this works I can merge the dev branch and close this issue for good.

I'll try this tonight.

@kylemanna This seems to do the trick!

I created an image as you suggested:
image

Ran the command:

docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it openvpn-test easyrsa build-client-full $CLIENTNAME nopass

image

Now just to check if revocation and removal of a generated client key passes I also ran this command:

docker run --rm -it -v $OVPN_DATA:/etc/openvpn openvpn-test ovpn_revokeclient ${CLIENTNAME} remove

The output looks like this as follows:
image

This output is slightly different when compared to kylemanna/openvpn:2.3:

docker run --rm -it -v $OVPN_DATA:/etc/openvpn kylemanna/openvpn:2.3 ovpn_revokeclient ${CLIENTNAME} remove

image

The last 3 lines which show what files were removed is not showing, probably not a big deal though.
Either way thanks for fixing this.

PS. Let me know if you need me to run anymore tests

@RafayAK thanks for testing, I'll merge dev branch into master and 2.4 branches and this will go away. Thanks for providing actionable logs and testing 馃憤馃徏

@RafayAK #621 should fix this for you, can you try re-pulling and confirm? I think we can call this closed!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rgarrigue picture rgarrigue  路  3Comments

jkroepke picture jkroepke  路  7Comments

Awatatah picture Awatatah  路  5Comments

antoninbouchal picture antoninbouchal  路  3Comments

konstantinj picture konstantinj  路  3Comments