Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The file '/etc/openvpn/vars' was not found #608

Closed
yell0w4x opened this issue Sep 26, 2020 · 20 comments
Closed

The file '/etc/openvpn/vars' was not found #608

yell0w4x opened this issue Sep 26, 2020 · 20 comments

Comments

@yell0w4x
Copy link

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.
@valerioferretti92
Copy link

Same thing happened to me.

@anthonymobile
Copy link

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

@yell0w4x
Copy link
Author

yell0w4x commented Sep 27, 2020

Also kylemanna/openvpn:2.3 works fine.

The issue is about kylemanna/openvpn:latest

@joeky888
Copy link

Workaround here #605 (comment)

@RafayAK
Copy link

RafayAK commented Sep 30, 2020

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

@RafayAK
Copy link

RafayAK commented Sep 30, 2020

using 2.3 works

@joshuacox
Copy link

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

@ebarault
Copy link

@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?

@kylemanna
Copy link
Owner

@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?

@kylemanna
Copy link
Owner

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.

@zalgonoise
Copy link

zalgonoise commented Nov 29, 2020

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!

@kylemanna
Copy link
Owner

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.

@ebarault
Copy link

ebarault commented Nov 30, 2020

Hi @kylemanna
with image 4fa457dfce43
image
I had to use this trick
touch /etc/openvpn/vars
ebarault/ovenvpn-ansible-role@e6b2213#diff-3d0ff1709ca48add100327bb2a468e6c508fb92a159c64c4f99ad1df89d9bddeR82

@kylemanna
Copy link
Owner

@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

@RafayAK
Copy link

RafayAK commented Dec 3, 2020

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.

@kylemanna kylemanna reopened this Dec 4, 2020
kylemanna pushed a commit that referenced this issue Dec 4, 2020
* This exists to import/export a number of easy-rsa default values but
  creates headaches for old volumes due to changes where easy-rsa
  insists on loading the var file if the environment variable is set.
* Going forward people should pass the variables via:
    `docker run -e EASYRSA_var ...` or
* Closes #608
@kylemanna
Copy link
Owner

@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.

@RafayAK
Copy link

RafayAK commented Dec 4, 2020

I'll try this tonight.

@RafayAK
Copy link

RafayAK commented Dec 4, 2020

@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

@kylemanna
Copy link
Owner

@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 👍🏼

@kylemanna
Copy link
Owner

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

chris42 pushed a commit to chris42/docker-openvpn that referenced this issue Mar 3, 2021
* This exists to import/export a number of easy-rsa default values but
  creates headaches for old volumes due to changes where easy-rsa
  insists on loading the var file if the environment variable is set.
* Going forward people should pass the variables via:
    `docker run -e EASYRSA_var ...`
* Closes kylemanna#608
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants