387 Commits
v0.1 ... master

Author SHA1 Message Date
10906ea6c7 [DOC] update documentation 2019-05-22 22:41:09 +02:00
e000adaeee [DBUG] correct the basic VPN address 2019-05-22 17:51:14 +02:00
b5c263f3c9 [DEV] specify the network ardress of the docker interface 2019-05-22 17:50:54 +02:00
fa23cd1f74 [DOC] add help to set configuration of service 2019-05-22 17:50:24 +02:00
74fbf013ad [DOC] add routing limitations 2019-05-22 17:49:57 +02:00
eeb82a509a [DEBUG] update config line 2019-05-22 17:49:36 +02:00
0c07c8a4de [DOC] update readme 2019-05-03 17:42:34 +02:00
b9aa38f4d7 [DEV] configure all 2019-05-03 14:41:23 +02:00
2f50498b3c [DEV] add ipv4 forwarding 2019-04-08 23:47:22 +02:00
8b97c10ca0 [DEBUG] corect the name of the docker in the docker-compose 2019-03-30 21:44:59 +01:00
5482607af1 [DEV] add basic docker-compose to test 2019-03-30 21:40:15 +01:00
a7226b4820 [DEV] update maintainer 2019-03-30 21:39:50 +01:00
ca50df06d6 Add a config parameter: Enable the notification to the client that the server restarts (explicit-exit-notify) 2019-03-30 14:45:32 +01:00
191722b843 Add a config parameter: enable log file mode (log/log-append) 2019-03-30 14:26:06 +01:00
f16f475b50 Add a config parameter: enable persistant client virtual IP (ifconfig-pool-persist) 2019-03-30 14:12:13 +01:00
10a072ca17 Add a config parameter: add capability to specify client config IP (client-config-dir) 2019-03-30 14:05:43 +01:00
7c82b535d7 Add a config parameter: Disable reduce prvilege of deamon 2019-03-30 13:47:23 +01:00
dbab08e92a Add a config parameter: change the status folder 2019-03-30 13:35:32 +01:00
Ivan Menshikh
79717903fa Fix indents in "quick start" (#454)
* fix indents in "quick start"

no more spaces before an command
2019-02-11 08:04:35 -08:00
Kyle Manna
47746e1bcb Merge pull request #418 from darkmattercoder/patch-extended-clientstatus
extended client status for EXPIRED or other errors
2019-01-22 22:27:09 -08:00
Kyle Manna
04df4789fb Merge pull request #436 from kunnix/patch-1
Update docker-openvpn@.service (docker.socket)
2019-01-22 22:24:19 -08:00
Kyle Manna
556c28fd15 Merge pull request #449 from rowanruseler/master
replaced 404 github link
2019-01-22 22:21:18 -08:00
Rowan Ruseler
ec6549238a replaced 404 github link 2019-01-22 11:39:54 +01:00
Kyle Manna
e83f0118e0 Merge pull request #446 from vansickle/patch-1
Update docker-compose debugging tips to include port publishing
2019-01-18 12:53:28 -08:00
Pavel Samokha
82dfe9cabd Update docker-compose debugging tips to include port publishing
According to the documentation docker-compose run command does not create any of the ports specified in the service configuration. So published ports should be specified in run command, otherwise you wouldn't be able to connect to the openvpn server.
2019-01-18 17:35:09 +03:00
Benoit V
bab729e2e4 Update docker-openvpn@.service (docker.socket)
Since version 1.12, Docker removed `docker.socket` <https://docs.docker.com/release-notes/docker-engine/>

The problem was already present on RPM systems (e.g. RHEL, Fedora, CentOS), and now also seems to affect Debian 9 (Stretch).

This change replaces `docker.socket` by `docker.service`.

It solves this problem:

```
> systemctl start docker-openvpn@.service
Failed to start docker-openvpn@.service: Unit docker.socket not found.
```

Related issues:

 - <https://github.com/kylemanna/docker-openvpn/issues/280>
 - <https://github.com/kylemanna/docker-openvpn/pull/286>
2018-11-08 11:24:57 +01:00
Kyle Manna
387d39e5d7 Merge pull request #426 from rca/patch-1
Update kernel "SubmittingPatches" link
2018-10-09 22:40:10 -07:00
Roberto Aguilar
2f3f99bc22 Use html version of SubmittingPatches URL 2018-10-10 00:14:53 -04:00
Roberto Aguilar
f856ee6a52 Update kernel "SubmittingPatches" link 2018-10-09 08:05:00 -04:00
Jochen Bauer
3771097bc9 corrected the output line, was accidentially wrong 2018-08-30 17:08:04 +02:00
Bauer, Jochen
ea19fbe932 extended client status for EXPIRED or other errors 2018-09-01 15:40:38 +02:00
Kyle Manna
cf136d40df README: Add Anchore Image Overview
* Adds a handy security fix.
2018-08-21 10:27:21 -07:00
Kyle Manna
83b939456e Merge pull request #400 from krlmlr/patch-1
README: Avoid logging for transient containers
2018-06-08 06:12:32 -07:00
Kirill Müller
5b2f6033c3 Avoid log driver for transient containers 2018-06-08 13:58:16 +02:00
Kyle Manna
73f8b02172 Merge pull request #383 from DZamataev/master
[bug fix] removes pushing 'comp-lzo' when it is enabled to avoid issues on Android
2018-05-05 19:44:40 -07:00
Denis Zamataev
49d36c2d64 implements setting 'comp-lzo no' on server conf by default 2018-05-03 15:19:02 +03:00
Denis Zamataev
e1bd5b6450 removes pushing 'comp-lzo' when it is enabled 2018-05-01 21:04:31 +03:00
Kyle Manna
2b8a82ab4a Merge pull request #382 from SizL75/patch-1
fixed typo
2018-04-29 15:59:16 -07:00
SizL75
092affef43 fixed type
missing space in line 372
2018-04-29 18:15:52 +02:00
Kyle Manna
5138981623 Merge pull request #380 from DZamataev/master
[bug fix] pushing comp-lzo setting to avoid error
2018-04-28 12:21:13 -07:00
Denis Zamataev
f75f2e17a3 implements pushing comp-lzo setting 2018-04-27 14:34:29 +03:00
Kyle Manna
23120e4757 Merge pull request #361 from fossabot/master
Add license scan report and status
2018-03-15 14:04:44 -07:00
fossabot
02e92db6bd Add license scan report and status
Signed-off-by: fossabot <badges@fossa.io>
2018-03-15 13:56:02 -07:00
Kyle Manna
d5497ba74a Merge pull request #351 from w2ak/master
ovpn_getclient: key-direction before tls-auth
2018-01-04 23:18:36 -08:00
w2ak
26589a118e [ovpn_getclient] key-direction before tls-auth
NetworkManager seems to be ignoring the `key-direction` directive when
it is after the `tls-auth` key, leading to issues as #268.

Signed-off-by: w2ak <w2ak@users.noreply.github.com>
2018-01-04 19:10:46 +01:00
Kyle Manna
30fcd3c6da Merge pull request #348 from miesgre/fix-genconfig-arm
Fix ovpn_genconfig script to work in arm architecture
2017-12-22 13:51:27 -08:00
Miguel Escriva
00ec5214e0 Fix ovpn_genconfig to work in arm architecture 2017-12-22 14:29:57 +01:00
Kyle Manna
fd8daa133a Merge pull request #331 from buchdag/patch-1
Add port sharing example to tcp doc
2017-11-23 14:03:51 -08:00
Nicolas Duchon
7b181c05d5 Add port sharing example to tcp doc 2017-11-23 21:41:34 +01:00
Kyle Manna
054a60c32d Merge pull request #325 from Silex/master
Fix outdated docs.
2017-11-01 20:11:02 -07:00
Philippe Vaucher
391f7e0b2f Fix outdated docs. 2017-11-01 17:30:54 +01:00
Kyle Manna
e82c2ce530 Merge pull request #324 from cglewis/master
MAINTAINER is deprecated, using LABEL now
2017-10-31 22:30:09 -07:00
cglewis
d7cf0c7e93 MAINTAINER is deprecated, using LABEL now 2017-10-31 20:12:28 -07:00
Kyle Manna
727231444b Merge pull request #321 from Silex/patch-1
Fix typos
2017-10-22 20:05:35 -07:00
Philippe Vaucher
0686b100b1 Fix typos 2017-10-20 14:35:40 +02:00
Kyle Manna
83d61c7c18 Merge pull request #306 from andrewrembrandt/patch-1
Typo/outdated edit config command?
2017-08-12 06:26:45 -07:00
Andrew Rembrandt
493865f441 Typo/outdated edit config command?
Looks like this was written for an earlier iteration?
2017-08-11 13:12:57 +01:00
Kyle Manna
84c87f5f7f Merge pull request #294 from mypetyak/systemd/capabilities
systemd: reduce container privilege by whitelisting NET_ADMIN capability
2017-07-10 22:23:33 -07:00
Kyle Manna
9f1ae1b989 Merge pull request #293 from mypetyak/docs/escape_contributing_markdown
docs: properly escape CONTRIBUTING markdown
2017-07-10 22:16:57 -07:00
Christopher Bunn
8f09769fdd systemd: reduce container privilege by whitelisting NET_ADMIN capability 2017-07-10 20:10:39 -07:00
Christopher Bunn
571e181152 docs: properly escape CONTRIBUTING markdown 2017-07-10 20:06:05 -07:00
Kyle Manna
925b08fec4 Merge pull request #283 from buchdag/genconfig-fix
Fix ovpn_genconfig repeatability issue
2017-07-08 11:06:36 -07:00
Nicolas Duchon
7a29e8e39b Extra client config is now an array 2017-06-21 02:21:52 +02:00
Nicolas Duchon
16fbc4019d Fix ovpn_genconfig for repeatability 2017-06-21 02:21:52 +02:00
Nicolas Duchon
63a2449705 Add test for ovpn_genconfig repeatability 2017-06-21 01:03:49 +02:00
Kyle Manna
1b8374f818 Merge pull request #281 from buchdag/crl-expire
Defaults easy_rsa CRL next update to 3650 days
2017-06-17 09:15:27 -07:00
Nicolas Duchon
8d7bc7e2c5 Set CRL next update to 3650 days 2017-06-17 13:17:20 +02:00
Nicolas Duchon
e30ee8eecf Add CRL next update test 2017-06-17 13:17:08 +02:00
Kyle Manna
e00a72a3f6 Dockerfile: master branch follows alpine:latest
The master branch will follow alpine:latest.  See `openvpn-2.x` branches
for more stability.

Related #267
2017-05-26 12:25:43 -07:00
Kyle Manna
d974c0ac6a README: Mention passphrase prompt and systemd init
* Enhance the documentation to mention that user interaction is
  necessary during the `ovpn_initpki`.
* Re-arrange the next steps part to point people to systemd init as well
  as docs directory.

Closes #266
2017-05-20 08:44:22 -07:00
Kyle Manna
c0ed8d468d Dockerfile: Drop edge/community for google-authenticator
* Use the primary repository now that google-authenticator is available
  from alpine:v3.5.

Related to #262
2017-05-17 09:27:30 -07:00
Kyle Manna
2a9059aa36 tests: Clean-up client + conf_options
Clean-up the mess that was here.  It's less error prone, shorter and
easier to read.
2017-05-13 10:52:47 -07:00
Kyle Manna
074a07e40e genconfig: Fix missing MTU required argument
This must have beeen broken for a long time.  Test case added to prevent
it from breaking again.

Closes #259
2017-05-13 09:50:18 -07:00
Kyle Manna
8c9d88b316 tests: client: Add client config test suite
* Test the client configuration to detect breakages
2017-05-13 09:50:18 -07:00
Kyle Manna
78d612d181 Merge pull request #253 from chepurko/patch-1 2017-05-11 11:21:14 -07:00
Kyle Manna
6bff62eb79 Dockerfile: Swtich from dl-4 to dl-cdn.alpinelinux.org
* At the time of this commit dl-4.alpinelinux.org was unreachable.
* Switch to the CDN instead of some hardcoded server.
2017-05-11 11:20:40 -07:00
Alexander Chepurko
8f2f27486c Add quoting into test.sh push options. 2017-05-11 10:55:46 -07:00
Alexander Chepurko
3ee5479d78 Push options need to be quoted.
Move the implementation to process_push_config.
2017-05-11 10:55:46 -07:00
Kyle Manna
909744dd78 Merge pull request #251 from buchdag/buchdag-revoke1
Fix certificate revocation
2017-05-10 09:37:03 -07:00
Nicolas Duchon
5aea8b914c Update documentation
Add ovpn_revokeclient usage to client.md and docker-compose.md
2017-05-10 18:08:11 +02:00
Nicolas Duchon
a091bef13b Create a script to handle client revocation
This script revoke the certificate corresponding to the commonName passed as first parameter, generate a new CRL, copies it to /etc/openvpn, make it readable by OpenVPN and optionally remove the crt, key and req file corresponding to the revoked certificate using "remove" as second parameter (removal of those files are required to generate a new client certificate using the revoked certificate's CN).
2017-05-10 18:08:11 +02:00
Nicolas Duchon
59644d953d Replace hardlinking of crl.pem with a copy
easyrsa gen-crl does not modify the crl.pem in place but rather remove the old file and create a new one, which means any hardlink to it will get broken again at each invocation of easyrsa gen-crl.

If hardlink to this file is not going to work anyway and we still need it to be readable by OpenVPN, we're better off copying it and chmod-ing it every time a new one is detected on container start, using the conditional expression file1 -nt file2.
2017-05-10 18:08:11 +02:00
Nicolas Duchon
dcf3791d54 Generate a CRL during PKI initialization 2017-05-10 18:08:11 +02:00
Nicolas Duchon
76546e1823 Add client revocation test 2017-05-10 18:08:11 +02:00
Kyle Manna
f996bbaa8e README: Clarify volume naming convention
* Use a better default that works with systemd service out of the box.
* Update upstart init script to follow convention.
2017-05-10 08:14:51 -07:00
Kyle Manna
861ed05c48 Merge pull request #254 from buchdag/buchdag-systemd.md
Clarify and complete systemd.md
2017-05-06 07:04:18 -07:00
Kyle Manna
ce690e5ab1 ovpn_run: Explicitly enable ipv6
On a recent build I ran in to the following error messages:

    Wed May  3 14:31:43 2017 /sbin/ip -6 addr add 2001:db8:0:4::1/64 dev tun0
    Wed May  3 14:31:43 2017 Linux ip -6 addr add failed: external program exited with error status: 2

This appears to be do to the fact that somewhere something defaulted the
kernel in the container to disable IPv6.  Not sure if this is my host or
the docker daemon.  Re-enable it explicitly for now until Docker gets
it's IPv6 act together.
2017-05-03 07:48:15 -07:00
Nicolas Duchon
e4821ec709 Clarify and complete systemd.md 2017-05-02 22:24:37 +02:00
Kyle Manna
808e2448b1 Merge pull request #244 from DerEnderKeks/patch-1
Removed double entry
2017-05-02 10:48:14 -07:00
DerEnderKeks
fe2cdebea2 Removed double entry
the removed line contained the same option as line 63
2017-03-25 19:41:31 +01:00
Kyle Manna
892a3c9a1c Merge pull request #234 from slamont/master
Add an option for setting different values for keepalive
2017-03-09 20:30:49 -08:00
Sylvain Lamontagne
a3c96bc881 Add test for keepalive 2017-03-09 20:58:46 -05:00
Sylvain Lamontagne
22fcaf9477 Add configuration for keepalive
* Add parameter to disable the push of block-outside-dns
* -d should really do what it was supposed to do
* Fix problem where comp-lzo would always be set regardless of the parameter
2017-03-09 20:35:52 -05:00
Kyle Manna
d454a20e80 Merge pull request #231 from mediatemple/only_block_when_road_warrior
Only block external dns when default route is pushed
2017-03-07 16:24:34 -08:00
Nate Jones
c8ba567333 only block external dns when default route is pushed 2017-03-07 23:21:17 +00:00
Nate Jones
21ae2fcef4 fix block-external-dns tests 2017-03-07 23:20:50 +00:00
Kyle Manna
24944b0a11 Merge pull request #226 from vielmetti/patch-1
Create Dockerfile.aarch64
2017-02-24 09:06:58 -08:00
Edward Vielmetti
b74cbd5c74 Create Dockerfile.aarch64
New Dockerfile to support aarch64 (ARMv8, arm64).
2017-02-23 13:59:43 -05:00
Kyle Manna
93c3a0453d README: Fix docker-compose mention
Previously rendered poorly on both GitHub and Docker Hub.
2017-02-23 08:01:08 -08:00
Kyle Manna
b868fa9093 Merge pull request #223 from outstand/extra-client-config
Add -E flag for adding extra client config
2017-02-19 09:34:09 -08:00
Ryan Schlesinger
fbb97918cf Only load config from temp file if not empty 2017-02-18 14:09:19 -08:00
Ryan Schlesinger
e282e1eed0 Add -E flag for adding extra client config 2017-02-18 13:53:35 -08:00
Kyle Manna
5236365fe1 Merge pull request #222 from maxromanovsky/patch-1
Docs: Fixed configuration restore instructions
2017-02-18 07:09:28 -08:00
Max Romanovsky
a293af4246 Fixed configuration restore instructions 2017-02-18 15:29:01 +03:00
Kyle Manna
47de917de5 Merge pull request #219 from r0p0s3c/iptables
move iptables/nat functionality to a function
2017-02-16 13:37:19 -08:00
r0p0s3c
cbf9cbf433 fix permission on test script 2017-02-16 15:28:31 -05:00
r0p0s3c
4fd8296a62 add iptables test to list of tests 2017-02-16 15:09:22 -05:00
r0p0s3c
0e3f34effd add test for iptables rules customization functionality 2017-02-16 15:04:06 -05:00
r0p0s3c
e8b568a0b9 add additional documentation clarifying calling of function, purpose, and how to override it 2017-02-16 14:57:52 -05:00
r0p0s3c
a2adb59d69 move iptables/nat functionality to a function (setupIptablesAndRouting)
This allows iptables rule update to be overridden by creating/supplying
that function in, for example, ovpn_env.sh
2017-02-16 14:57:52 -05:00
Kyle Manna
f4351bb0dd Merge pull request #216 from peterrus/patch-1
using run instead of exec
2017-02-12 09:34:14 -08:00
peterrus
14c45f418c using run instead of exec
It is more in line with the other commands we run earlier. Shouldn't have any negative effects right?
2017-02-12 13:50:42 +01:00
Kyle Manna
7627f8e9f9 Merge pull request #215 from tilosp-docker/dev
Connect to the OpenVPN Server over IPv6
2017-02-08 09:10:23 -08:00
Tilo Spannagel
26635395b2 README: Connect to the OpenVPN Server Over IPv6 2017-02-08 16:20:31 +01:00
Tilo Spannagel
abdf537da5 Added IPv6 support to client script
Signed-off-by: Tilo Spannagel <development@tilosp.de>
2017-02-08 09:41:48 +01:00
Tilo Spannagel
1d2a2e8b29 Added IPv6 support
Signed-off-by: Tilo Spannagel <development@tilosp.de>
2017-02-08 09:29:47 +01:00
Kyle Manna
f487184a4a Merge pull request #214 from yanndegat/master
Fix  OVPN_ADDITIONAL_CLIENT_CONFIG
2017-02-06 06:59:43 -08:00
yanndegat
1a984ba9cd Fix OVPN_ADDITIONAL_CLIENT_CONFIG
OVPN_ADDITIONAL_CLIENT_CONFIG isn't available in combined mode
2017-02-06 15:49:31 +01:00
Kyle Manna
aaf2c0fee1 Merge pull request #212 from hadim/compose-doc
Update documentation for docker-compose
2017-01-29 09:02:11 -08:00
Hadrien Mary
c4fc888dca Update documentation for docker-compose 2017-01-28 19:07:51 -05:00
Kyle Manna
be165e209e Merge pull request #208 from lhopki01/master
Fix issue with connection resetting every hour when using otp.
2017-01-26 22:42:04 -08:00
Luke
ef8221372d change test to bring in line with others 2017-01-26 17:53:53 +00:00
Luke
c9ada1eac4 reneg-sec needs to be set to 0 when using otp because otherwise the connection will be ask for a otp every hour. Tests added to make sure it's there when otp is enabled 2017-01-25 14:06:19 +00:00
Kyle Manna
2cc170f001 Merge pull request #209 from DrMurx/fix-custom-route
bugfix: custom route definition didn't override default
2017-01-24 17:29:23 -08:00
Jan Kunzmann
8f304ea3fe bugfix: custom route definition didn't override default 2017-01-25 01:25:08 +01:00
Luke
a20c63893e modify command in documentation too 2017-01-24 14:42:51 +00:00
Luke
fbdc8e32c6 remove debugging extra 2017-01-24 14:40:48 +00:00
Luke
3ebc4903d8 automatically add reneg-sec 0 to client and server configs when otp is being used to avoid connection resetting every hour. Edit docs to make clear that a more secure cipher needs to be selected to use with otp to avoid the connection being reset every 64 MB of data 2017-01-24 14:37:48 +00:00
Kyle Manna
1129eb09bc systemd: Remove read-only flag on volume
* The read-only flag will create issues with those trying to add
  certificates to the data volume.
2017-01-17 07:27:21 -08:00
Kyle Manna
b07b4957f8 Merge pull request #204 from kylemanna/docs_systemd
Document systemd service usage
2017-01-16 15:45:45 -08:00
Kyle Manna
4725f3621f README: Add reference to the systemd doc
* Encourage users to use systemd to manage the Docker container.
2017-01-16 14:12:22 -08:00
Kyle Manna
c6d0a71901 README: Remove extraneous references to problems
We're not going to reference all the thing potential issues that could
go wrong in the README.  Remove this to keep it concise.
2017-01-16 14:12:22 -08:00
Kyle Manna
4737654cb2 docs: Add systemd documentation
* Describe how to use the reference service.
* Closes #200
2017-01-16 14:12:22 -08:00
Kyle Manna
5e95b64ff1 Merge pull request #202 from Gmentsik/combined-save-bugfix
bugfix: combined-saved was not making directory
2017-01-12 08:12:24 -08:00
gergely.mentsik
4fd33ab077 bugfix: combined-saved was not making directory 2017-01-12 12:49:24 +01:00
Kyle Manna
093fc9fafc bin: copy_server_files: Backup crl.pem
* Back-up the crl.pem file if present.
* Closes #198
2017-01-05 15:58:10 -08:00
Kyle Manna
14d6f7f491 docs: backup: Fix missing volume creation
* Create the volume before extracting.
* Resolves #195
2017-01-05 15:58:10 -08:00
Kyle Manna
431c4a3e82 Dockerfile: Bump to Alpine 3.5
* Update to the latest and greatest for testing.
* Closes #187
2017-01-05 15:58:10 -08:00
Kyle Manna
70373df974 Merge pull request #192 from ryansch/patch-1
Update README.md
2017-01-02 18:57:24 -08:00
Ryan Schlesinger
4328fe2071 Update README.md
The tests have the image name hardcoded to kylemanna/openvpn.  Attempting to run with any other name causes the tests to run against the latest image from docker hub.
2017-01-02 16:50:34 -08:00
Kyle Manna
1e24ee19d9 Merge pull request #191 from vielmetti/patch-2
update clients.md ; typo fix
2016-12-31 01:43:00 -08:00
Kyle Manna
acc84e016c Merge pull request #190 from vielmetti/patch-1
add logging warning to paranoid.md
2016-12-31 01:42:14 -08:00
Edward Vielmetti
876a686e7d update clients.md ; typo fix
"revocation" for "revokation", no other changes
2016-12-31 01:34:01 -05:00
Edward Vielmetti
6028a2b5b7 add logging warning to paranoid.md
Update documentation with logging warning; closes #189 .
2016-12-31 01:27:28 -05:00
Kyle Manna
9d1c90cde7 README: Explicitly create volume container
* Implicit creation seems to have issues.
* Resolves issue #175
2016-11-21 10:02:10 -08:00
Kyle Manna
d2c5648825 README: Delete dead example service
* Service is no longer running due to abuse.  Surprise.
2016-11-04 14:42:53 -07:00
Kyle Manna
51270aae82 Merge pull request #162 from slamont/master
Too many arguments while pushing route
2016-09-24 18:02:28 -07:00
Sylvain Lamontagne
72a3c8a001 Fix for regression
As I reworked the push options, a bug got introduced where a duplication
of push in the config for the DNS dhcp-options would make it to fail.
There was no tests covering this, so I did not catch it earlier.

I've add the missing tests and fix the bug
2016-09-22 18:12:45 -04:00
Sylvain Lamontagne
2e943378d1 Too many arguments while pushing route
So I was trying to push a route to my client and the script failed with
'too many arguments', I reworked this part and took the opportunity to
rework a little bit the way push and routes were handled.

I also added some tests and validated that what I changed would not
break what was there before.
2016-09-22 16:02:59 -04:00
Kyle Manna
bdeaff217c Merge pull request #161 from slamont/master
Add doc for extra config use and fixed unlikely unbound variable
2016-09-20 10:10:14 -07:00
Sylvain Lamontagne
3f3a4ea9be Fix Markdown for easier display 2016-09-20 13:01:29 -04:00
Sylvain Lamontagne
e8eb1dda0c Added extra config doc in faqs and fixed an unlikely unbound variable 2016-09-20 12:53:29 -04:00
Kyle Manna
97f8677a03 Merge pull request #160 from slamont/master
Add multiple extra config option
2016-09-20 09:36:01 -07:00
Sylvain Lamontagne
ac3cb44d85 Added test for multiple extra options 2016-09-20 12:01:56 -04:00
Sylvain Lamontagne
39996ed568 Fix Unbound Variables 2016-09-16 18:50:48 -04:00
Sylvain Lamontagne
1807bc6dc4 Add multiple extra config option
Add bash traceback in case an error occured
2016-09-16 18:42:45 -04:00
Kyle Manna
a17dfd7808 copy_server_files: Include ccd directory
* Include the client configuration directory
* Related to #133
2016-09-16 07:38:19 -07:00
Kyle Manna
62b6cc3db9 docs: paranoid: Describe how to do 4096 RSA keys
* For the paranoid of course. :)
* Someday elliptic curve?
* Closes #154
2016-09-03 16:26:31 -07:00
Kyle Manna
379766fc5e misc: Switch from data container to data volume
* Use the `docker volume` mechanism.
* Less confusing and makes more sense.
* Released in ~ docker v1.9
2016-09-03 16:17:50 -07:00
Kyle Manna
9e7b363758 genconfig: Clean-up usage() display
* Semi-sorted order.
* Move arguments with flags up.
2016-09-03 15:45:55 -07:00
Kyle Manna
0c743d91b6 Merge pull request #156 from fabn/patch-1
Updated otp documentation with right repository name and debug info
2016-09-03 10:48:04 -07:00
Fabio Napoleoni
a3d5ac8e90 Updated otp documentation with right repository name and debug info 2016-09-03 13:23:19 +02:00
Kyle Manna
8027454cb5 google-auth: Pull from community repository again
* Pull from upstream community repository instead of building inline.
2016-09-02 21:57:23 -07:00
Kyle Manna
e3a68c784a CONTRIBUTING: Update test path
* Update to follow new testing scheme.
2016-08-31 12:44:57 -07:00
Kyle Manna
bcf8dc51eb test: Migrate from old test scripts
* Switch to upstream Docker inspired test suite.
* Major disadvantage:  Seeing the stdout log. To be researched later.
2016-08-31 12:42:53 -07:00
Kyle Manna
65bebaebd8 test: Migrate conf_options test
* Move the configuration options to new docker test suite.
2016-08-31 11:53:03 -07:00
Kyle Manna
93098fb165 travis: Call docker test suite run.sh
* Invoke the same as the upstream repo.
2016-08-31 11:41:39 -07:00
Kyle Manna
ee5d6a6b8a test: Start to migrate to docker's upstream tests
* Follow the upstream test suite's conventions.
* More migration to follow.
2016-08-31 11:39:36 -07:00
Kyle Manna
e700aa1f9f travis: Use upstream docker tests
* Run the upstream docker unit tests
2016-08-31 11:12:38 -07:00
Kyle Manna
96668fedbb travis: Clean-up docker containers
* Clean-up containers that just display the version.
2016-08-31 11:08:08 -07:00
Kyle Manna
dc9c30ff5a google-authenticator: Manually build Alpine package
* Build the Alpine package directly
* Resolves #153
2016-08-31 09:57:42 -07:00
Kyle Manna
baf9504875 Merge pull request #149 from myplacedk/master
README: Add info on docker-compose
2016-08-04 17:46:20 -07:00
Niels Ulrik Andersen
438316a895 docs: docker-compose bugfix 2016-08-04 21:23:10 +02:00
Niels Ulrik Andersen
85680566d3 Add info on docker-compose 2016-08-04 20:16:42 +02:00
Kyle Manna
6899426152 README: Update image layers badge
* RIP Image Layers
2016-08-03 15:32:59 -07:00
Kyle Manna
698be88ce0 tests: Fix harmless typo in options test
* Fix a minor typo, use a name to avoid a namespace clash
* Closes #144
2016-07-08 10:44:37 -07:00
Kyle Manna
a1071add9e README: Update Image Layers shield
* Switch to a different provider for the image layer shield.
2016-07-07 12:42:22 -07:00
Kyle Manna
dcc33e2483 Merge pull request #143 from sandhu/master
Fix for Windows 10 DNS Leak
2016-07-05 11:44:18 -07:00
Kyle Manna
0a5a792519 Merge pull request #138 from Caerbannog/patch-1
Add "key-direction 1" to client .ovpn
2016-07-05 11:44:05 -07:00
Achint Sandhu
bcedc8d6d6 Fix for Windows 10 DNS Leak
The patch includes an update to the OpenVPN server config to
address a DNS leak when using Windows 10, as documented at:
https://community.openvpn.net/openvpn/ticket/605
2016-07-05 13:29:45 -04:00
Kyle Manna
ff731723d4 Merge pull request #141 from meonkeys/upgrade-base-alpine
Derive from alpine 3.4 instead of 3.2
2016-06-25 21:09:47 -07:00
Adam Monsen
b81b2dd472 Derive from alpine 3.4 instead of 3.2
To work around known vulnerabilities in alpine 3.2 such as CVE-2016-2177
and CVE-2016-2178.

See https://github.com/kylemanna/docker-openvpn/issues/140
2016-06-24 13:53:45 -07:00
Kyle Manna
4f269704c4 Merge pull request #135 from efrecon/master
Automatically creating CCD directory
2016-06-23 06:28:05 -07:00
Emmanuel Frecon
3e747b353e Sending key to proper location! 2016-06-23 12:20:13 +02:00
Martin d'Allens
dac38246bd Add "key-direction 1" to client .ovpn
Adding this setting avoids connection errors on some clients, when the .ovpn file is imported directly in Gnome NetworkManager.

Server logs:
    Authenticate/Decrypt packet error: packet HMAC authentication failed
    TLS Error: incoming packet authentication failed from ...

Client logs:
    nm-openvpn: TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
    nm-openvpn: TLS Error: TLS handshake failed

NetworkManager version: 1.2.0
openvpn version: OpenVPN 2.3.10
2016-06-13 12:09:54 +02:00
Emmanuel Frecon
c12fdcd83f Automatically creating CCD directory 2016-06-08 09:14:08 +02:00
Kyle Manna
50f387169a tests: dual-proto: Kill both background servers
* Kill both the udp and tcp background jobs.
2016-06-01 15:05:41 -07:00
Kyle Manna
22cc82d21d tests: dual-proto: Fail gracefully on firewall
* Firewall was already configured, don't exit the unit test.
2016-06-01 14:44:35 -07:00
Kyle Manna
14827df71d Merge branch 'dual-proto' of git://github.com/dave-burke/docker-openvpn into dave-burke-dual-proto 2016-06-01 14:44:16 -07:00
Kyle Manna
e8eb47ef2b test: Add a simple completion message and test cnt
* Simplify the review of the test log by looking for a magic line.
2016-06-01 14:43:28 -07:00
Kyle Manna
30adfd5632 tests: basic: Fail gracefully on firewall
* Firewall was already configured, don't exit the unit test.
2016-06-01 13:41:25 -07:00
Kyle Manna
f3a24fee60 travis: Fail when a unit test fails
* Oops, this never actually aborted when something went wrong.
* Fix that and abort.
* Print a brief message about the last script run that blew up.
2016-06-01 13:36:31 -07:00
Kyle Manna
61bb4a933c travis: Add test header
* Print a brief header to describe the test about to be run
2016-06-01 12:40:00 -07:00
Dave Burke
a5b9ade314 Add dual protocol documentation 2016-05-31 21:12:30 -05:00
Dave Burke
5d436643b2 Add dual protocol test 2016-05-31 21:12:30 -05:00
Dave Burke
d77ba5e1e8 Combine user args with generated args
Generated arguments will be added only if matching arguments were not
specified by the user. User arguments will be placed after generated
arguments. This allows the user to override any generated configuration
values.
2016-05-31 21:11:03 -05:00
Dave Burke
097376db75 Set working dir in ovpn_run instead of Dockerfile 2016-05-28 22:34:41 -05:00
Kyle Manna
caffc0b715 Merge pull request #130 from rgarrigue/patch-1
Update README.md
2016-05-25 22:18:36 -07:00
Rémy G
7eede0d8e5 Update README.md
Typo fix
2016-05-25 20:44:12 +02:00
Kyle Manna
22f90831cf Merge pull request #127 from mediatemple/add_extra_config
allow specifying extra config
2016-05-17 21:26:14 -07:00
Nate Jones
793f83d620 adding tests for extra server config 2016-05-17 08:42:22 -07:00
Nate Jones
191cb45106 allow specifying extra config 2016-05-16 09:56:27 -07:00
Kyle Manna
df63db02a0 Merge pull request #126 from mediatemple/add_ovpn_listclients
adding ovpn_listclients script
2016-05-11 21:43:42 -07:00
Nate Jones
d3fcec15f1 adding ovpn_listclients script 2016-05-11 16:02:27 -07:00
Kyle Manna
98f9681d3e Merge pull request #122 from TheNotary/readme-debug-section
Debugging tips added to readme
2016-04-23 16:21:48 -07:00
TheNotary
74ba753f70 Created a debug section in readme 2016-04-23 10:52:39 -07:00
Kyle Manna
cd8fd6afaa Merge pull request #119 from rudijs/fragment-option
Add openvpn.conf gerneration -f fragment directive option
2016-04-11 18:54:59 -07:00
Rudi Starcevic
9ea4815a74 Fix incorrect local image being used 2016-04-06 15:21:13 +08:00
Rudi Starcevic
74bfad0aac Add openvpn.conf gerneration -f fragment directive option 2016-04-06 15:06:02 +08:00
Kyle Manna
ed51116fb6 docs: Add contribution guidelines
* High level overview of contribution guidelines.
2016-04-04 23:49:14 -07:00
Kyle Manna
eb22992a2f Merge pull request #102 from fabn/otp
Two factor authentication using a token application
2016-03-14 07:42:30 -07:00
Kyle Manna
286676879d Merge pull request #107 from croepha/selinux
Updated SELinux docs
2016-02-23 21:56:59 -08:00
David Butler
42bf842202 Updated SELinux docs
for hosts not allowing module loading
2016-02-23 12:05:13 -06:00
Kyle Manna
bd51bb273e Merge pull request #104 from croepha/selinux
Selinux policy and docs
2016-02-17 15:07:15 -08:00
Kyle Manna
70b70e298d Merge pull request #105 from mypetyak/master
Added documentation details on using TCP protocol.
2016-02-17 15:06:43 -08:00
Christopher Bunn
95c260a97a Added documentation details on using TCP protocol. 2016-02-16 22:44:10 -08:00
Fabio Napoleoni
35c9103454 Updated Alpine Linux packages, including pamtester 2016-02-15 21:01:52 +01:00
Fabio Napoleoni
d481313311 Back to Alpine Linux using packaged version of google-authenticator 2016-02-11 18:10:51 +01:00
David Butler
9b824fb35a Fix typo 2016-02-10 13:01:54 -06:00
David Butler
7a9abf4c14 Update README.md 2016-02-10 12:37:56 -06:00
David Butler
44055aa687 added docs for SELinux policy file 2016-02-10 12:34:35 -06:00
David Butler
8356a664d8 Added linux policy file 2016-02-10 12:25:45 -06:00
Fabio Napoleoni
ba7b925a9f Using a different volume name for otp test, should allow tests to run 2016-02-10 17:12:49 +01:00
Fabio Napoleoni
517ad6aeb2 Implemented tests for 2 factor authentication 2016-02-10 16:59:15 +01:00
Fabio Napoleoni
9c6f3311a1 Fix for Dockerfile, trailing slash is needed. 2016-02-07 14:45:28 +01:00
Fabio Napoleoni
dc4656ef48 OTP documentation 2016-02-07 14:30:56 +01:00
Fabio Napoleoni
e8d93ea4fa Use $USER@$OVPN_CN for OTP label. 2016-02-07 13:22:20 +01:00
Fabio Napoleoni
10dd404159 Fixes pam authentication when dealing with virtual users 2016-02-07 03:48:44 +01:00
Fabio Napoleoni
607063b358 Do not cache user credentials 2016-02-07 02:53:43 +01:00
Fabio Napoleoni
bb3d1add3c Export user pass option in client when OTP is enabled 2016-02-06 21:40:11 +01:00
Fabio Napoleoni
c24a22deea Allow interactive usage 2016-02-06 21:38:26 +01:00
Fabio Napoleoni
6084261943 Improved script for user OTP generation, tested with pamtester 2016-02-06 21:31:08 +01:00
Fabio Napoleoni
5ca92a2c5e Fixed configuration for pam module to allow login of non existing user accounts, i.e. VPN only users. 2016-02-06 21:20:34 +01:00
Fabio Napoleoni
dd719c1f11 Save OTP variable in server env 2016-02-06 20:25:03 +01:00
Fabio Napoleoni
6fcebf9adb Server side configuration for OTP 2016-02-06 20:23:59 +01:00
Fabio Napoleoni
86d2a52f85 Install google authenticator in jessie 2016-02-06 19:45:42 +01:00
Fabio Napoleoni
1623afe651 Reverted to debian jessie 2016-02-06 19:40:54 +01:00
Kyle Manna
e7d0d4ea0e ovpn_run: Fix sysctl IPv6 forwarding write
* I'm not sure if this ever worked without the `-w` flag.  Perhaps in an
  old version of sysctl?
2015-12-29 13:33:55 -08:00
Kyle Manna
e50f4dcc23 Merge pull request #90 from ypid/added-badges
Added badges showing a few key facts next to the CI status.
2015-12-21 16:05:35 -08:00
Robin Schneider
96d17bb5a7 Added badges showing a few key facts next to the CI status.
* Updated Docker Hub URL to new schema.
2015-12-21 22:19:22 +01:00
Kyle Manna
f2111006ad Merge pull request #82 from vielmetti/patch-1
Split tunnels, as documented in #51
2015-11-30 13:43:22 -08:00
Edward Vielmetti
d520a58ec4 Split tunnels, as documented in #51
Taking text from #51 and putting in into the FAQ to make it that much easier to find.
2015-11-30 16:27:46 -05:00
Kyle Manna
1c290e60db Merge branch 'compression'
Closes #81
2015-11-29 10:16:13 -08:00
unknown
2fa3abe064 fixed getopts argument typo. removed ":" before "z" 2015-11-29 10:15:15 -08:00
Christian Tawfik
2650d4a286 COMP-lzo param is set in client config, if defined in server. 2015-11-29 10:15:15 -08:00
Christian Tawfik
2abbcf1999 added config param to enable COMP-LZO compression 2015-11-29 10:14:07 -08:00
Kyle Manna
818e8682d1 Dockerfile: EasyRSA is in community now
* No longer in testing.
2015-11-28 09:10:55 -08:00
Kyle Manna
3edc12a6b7 Merge pull request #78 from gdb/gdb/master
Respect the -D flag
2015-11-01 10:38:26 -08:00
Greg Brockman
ded4414ef4 Respect the -D flag
It looks like edfbffb85f caused the
OVPN_DNS variable to start being ignored, meaning the -D flag was a
no-op.
2015-10-31 19:39:32 -07:00
Kyle Manna
f277449569 Merge pull request #76 from discordianfish/push-custom-dns-servers
Support pushing custom DNS servers
2015-10-16 07:44:53 -07:00
Johannes 'fish' Ziemke
edfbffb85f Support pushing custom DNS servers 2015-10-16 15:41:22 +02:00
Kyle Manna
98cf2128c7 Merge pull request #70 from kylemanna/alpine
Switch to Alpine for Base
2015-10-04 08:24:18 -07:00
Kyle Manna
c3d526fd67 Merge branch 'master' into alpine 2015-09-29 11:43:08 -07:00
Kyle Manna
1498795de2 ovpn_copy_server_files: Use short flags with rm
* The busybox tool in the alpine distro doesn't support long flags.
2015-09-29 11:42:17 -07:00
Kyle Manna
f00de363c7 ovpn_copy_server_files: Copy files without rsync
* Hack around the missing rsync by using tar to preserve the directory
  structure.
* Fixes #73
2015-09-29 11:28:04 -07:00
Kyle Manna
7f58926aa2 tests: Add test for paranoid ovpn_copy_server_files
* Make sure this works
* Related to #73
2015-09-29 10:44:53 -07:00
Kyle Manna
ba7860cced Merge branch 'travis-ci' into alpine 2015-09-22 15:03:20 -07:00
Kyle Manna
98340d7602 Merge pull request #71 from kylemanna/travis-ci
Add Travis CI Testing
2015-09-22 15:02:50 -07:00
Kyle Manna
9459804a1d README: Add Travis CI build status
* Keeps people honest
2015-09-22 14:36:19 -07:00
Kyle Manna
b298eb16bc travis-ci: Extend test to actually do a connection
* Start the server
* Start the client
* Connect
* Profit
2015-09-22 14:32:55 -07:00
Kyle Manna
2c3284acd6 travis-ci: Initial build test
* Build and reports package version.
2015-09-22 08:59:15 -07:00
Kyle Manna
23f66094ff alpine: Use easy-rsa in testing branch of alpine
* Simplifes the Dockerfile significantly.
* No need for curl.
2015-09-10 10:33:05 -07:00
Kyle Manna
3da0efa5bc alpine: Use alpine as base image instead of Debian
* Debian Jessie -> Alpine 3.2: 150MB -> 15MB
2015-09-08 10:07:16 -07:00
Kyle Manna
314eb15507 Merge pull request #69 from ypid/docker_no_network_paranoid_doc
Only setup networking for containers which need it.
2015-09-08 06:54:42 -07:00
Robin Schneider
ee9f4531ad Only setup networking for containers which need it.
This should mitigate a hypothetical compromise of the scripts used to
manage the CA and other sensitive material.

The examples should still work and make sense although I have not tried
all of them with this change applied.

Note that I did not append the --net=none to all examples because in
some cases network is probably wanted.

* Changing this for all docs was not accepted by @kylemanna.
  https://github.com/kylemanna/docker-openvpn/pull/65#issuecomment-138559257
2015-09-08 15:34:58 +02:00
Kyle Manna
41f7fd22ad Merge pull request #66 from ypid/copy_server_not_symlink
ovpn_copy_server_files: Copy openvpn.conf instead of symlinking locally.
2015-09-07 20:03:09 -07:00
Kyle Manna
d08df0189b Dockerfile: Chmod everything in /usr/local/bin
* Keep it simple.
* Nothing should ever be put in bin that isn't excutable.
2015-09-07 19:21:55 -07:00
Kyle Manna
d96378a391 Dockerfile: Streamline tarball extraction
* No point in writing it to the disk and then deleting it
* Extract it in place
2015-09-07 19:21:07 -07:00
Julian Vassev
32029c98c8 Update to easyrsa 3.0
virtual size 60mb smaller, git replaced by curl
2015-09-08 01:11:32 +03:00
Robin Schneider
3df53012b6 ovpn_copy_server_files: Copy openvpn.conf instead of symlinking locally.
Symlinked files can be resolved by rsync when using the configuration on remote
servers but for local testing having the actual file is beneficial.
2015-08-27 21:19:27 +02:00
Kyle Manna
74c4ca94a7 Merge pull request #62 from ypid/docs-rework
Updated documentation.
2015-08-26 08:42:58 -07:00
Kyle Manna
b96a91e876 Merge pull request #63 from ypid/allow_ciper_setting
Allow to change security related options tls-cipher, cipher and auth.
2015-08-26 08:42:30 -07:00
Kyle Manna
407506392f Merge pull request #64 from ypid/copy_server_files-ensure-rm
ovpn_copy_server_files: Ensure that no other keys then the one for the server is present.
2015-08-26 08:41:24 -07:00
Robin Schneider
bf9f58f8e1 Reverted Github flavored markdown Shell syntax highlighting.
Sorry again for the inconvenience.
2015-08-26 13:12:18 +02:00
Robin Schneider
050d4a1f82 ovpn_copy_server_files: Ensure that no other keys then the one for the server is present.
When creating a multi-server setup I used a partly copied, partly
symlinked directory structure for the different servers after creating a
certificate for each server with `easyrsa build-server-full`. In that
process I also copied the `server` directory.
The rsync command does not delete files which are not excluded so it
included the correct server key and the original one which can be a
security risk.
2015-08-26 13:00:17 +02:00
Robin Schneider
d6209eebc2 Allow to change security related options tls-cipher, cipher and auth. 2015-08-26 12:56:40 +02:00
Robin Schneider
2d16231c3c Updated documentation.
* Related to https://github.com/kylemanna/docker-openvpn/pull/54
* Allow better syntax highlighting.
* Added/Fixed hyperlinks.
* Spelling.
2015-08-25 12:40:02 +02:00
Kyle Manna
15ac3c89b0 Merge pull request #60 from wernerb/master
Set custom OVPN_NATDEVICE when using --net=host to custom interface.
2015-08-24 09:04:51 -07:00
Werner Buck
0181bb93d6 Add ability to set OVPN_NATDEVICE to target specific interface when using net=host 2015-08-24 17:19:40 +02:00
Kyle Manna
e557222753 Merge pull request #59 from thomastweets/master
Add a parameter to use TAP instead of TUN device.
2015-08-18 16:38:18 -07:00
Thomas Emmerling
3703d3afc3 Add a parameter to use TAP instead of TUN device. 2015-08-19 00:46:07 +02:00
Kyle Manna
d3d11b660a docs: Update docker key resource
* Update link to docker.com as the previous URL would redirect
* Add `-L` flag to follow future location headers
2015-08-15 19:21:09 -07:00
Kyle Manna
4868a35bd3 docs: Second pass on IPv6
Still needs more work, but updated to reflect the templated systemd file.
2015-08-12 14:08:59 -07:00
Kyle Manna
bce012b92a Merge pull request #57 from ypid/fixed-ipv6-docs
Quick read of ipv6 docs and small fixes.
2015-08-12 13:58:57 -07:00
Robin Schneider
7007c49d34 Reverted docker service restart command to use systemctl directly. 2015-08-12 22:04:01 +02:00
Robin Schneider
c679404695 Quick read of ipv6 docs and small fixes.
* Why on earth does one directly edit the systemd/system/docker.service
  file just to add a start argument?
* Fixed typos.
* I have not fully tested it yet, but I will when I have time.
2015-08-11 23:18:41 +02:00
Kyle Manna
2508abd5ad run: Fail gracefully when IPv6 fails
* Fail gracefully but complain in the log when --privileged isn't used
  for docker run.
* IPv6 is in development for the time being.
* Closes #56
2015-08-09 18:04:05 -07:00
Kyle Manna
149cd3a3a3 systemd: Set upstream image to latest
* No longer is the image tagged dev following the merge.
2015-08-07 12:12:37 -07:00
Kyle Manna
1f47f361eb Merge pull request #55 from kylemanna/dev
Merge Development Branch
2015-08-07 11:14:59 -07:00
Kyle Manna
d89cbe5ba3 Merge pull request #54 from pushrax/remove-dh-client-config
Remove dh param from client config
2015-08-05 06:38:23 -07:00
Justin Li
02c3ee63a1 Remove dh param from client config 2015-08-04 23:07:47 -04:00
Kyle Manna
34d9601e6e ovpn_run: Assume /etc/openvpn is read-only
* Systemd service currently marks the mount as read-only, and this is
  regarded as good practice for server/daemon only operation.
* Don't create /etc/openvpn/ccd as the mount may be read-only.
* Append the client-config-dir command line argument if it is found to
  avoid mkdir operation.
* Mount can easily be modified using a different docker run line with
  ":ro" on the volume mount.
2015-07-27 20:26:43 -07:00
Kyle Manna
5a1e642177 init: systemd: Use systemd style config overrides
* RIP hacky /etc/default/foo style environement sourcing hack
2015-07-11 08:50:24 -07:00
Kyle Manna
313d1e756c init: Update init file to be a template
* Useful for systems with several OpenVPN docker containers running.
2015-07-11 08:31:58 -07:00
Kyle Manna
7a3cc674f0 docs: backup: Correct mindless typos
* Correct minor grammatical typos
2015-07-10 11:27:35 -07:00
Kyle Manna
08d8116e31 docs: faq: How do I edit openvpn.conf?
* It gets asked too many times.
2015-07-06 08:55:42 -07:00
Kyle Manna
017580fdaa docs: ipv6: Add section enabling Docker IPv6
* Oops, doesn't work without this.
2015-07-05 22:11:19 -07:00
Kyle Manna
0edc11b585 docs: docker: Install apt dependencies
* Otherwise it's annoying without it.
2015-07-05 21:52:19 -07:00
Kyle Manna
155c4d4b90 docs: docker: Crash course on installation
* Nothing less nothing more.
2015-07-05 21:48:10 -07:00
Kyle Manna
56a8e735b6 docs: ipv6: Add initial development guide
* Work in progress.
2015-07-05 21:28:44 -07:00
Kyle Manna
9c8d195880 init: Add docker-openvpn systemd service file
* Works with IPv6 thanks to ExecStartPost.
2015-07-05 21:08:47 -07:00
Kyle Manna
e6f7904344 run: Add IPv6 forwarding if default route
* Enable IPv6 forwarding if docker daemon provided a default route
* For now this requires the --privileged flag, but this could be hacked
  around using `ip netns` madness.
2015-07-05 21:07:06 -07:00
Kyle Manna
6aca273d89 getclient: Use openssl to prune comments
* The EasyRSA tools create a certificate file with all the metadata
  readable.  This makes the config file larger then it needs to be, so
  prune it.
* Retrieve text files with `openssl x509 -in <crt> -noout -text`
2015-07-05 21:07:04 -07:00
Kyle Manna
e3655b5115 init: Move upstart file to init directory
* No functional changes.
2015-07-05 21:07:00 -07:00
Kyle Manna
1078267db5 Dockerfile: Clarify port mapping
* Extend comment about port mapping since everyone seems to want to run
  on port 443/tcp.
* Accept that nobody (except the already competent) will read the
  comment and ask anyway.
2015-06-21 22:55:16 -07:00
Kyle Manna
27bb8c7149 README: Add example service
* Example service to demo the container.
2015-06-21 22:35:46 -07:00
Kyle Manna
868da2ddac Merge pull request #49 from ypid/copy-server-create-ccd
Create ccd directory to prevent error if /etc is mounted read-only.
2015-05-31 16:00:39 -07:00
Robin Schneider
7399ff7bbd Create ccd directory to prevent error if /etc is mounted read-only.
* mkdir: cannot create directory '/etc/openvpn/ccd': Read-only file system
2015-05-31 22:10:54 +02:00
Kyle Manna
e0f7856e6f Merge pull request #48 from ypid/optimized-copy-server-script
Optimized ovpn_copy_server_files script. No need to copy the config files.
2015-05-30 16:09:50 -07:00
Kyle Manna
a52a9cdc8d Merge pull request #47 from ypid/added-raw-client-config
Added variable OVPN_ADDITIONAL_CLIENT_CONFIG use arbitrary openvpn configuration options.
2015-05-30 16:09:25 -07:00
Kyle Manna
d1ae4dd305 Merge pull request #46 from ypid/fixed-docs
Using better example in docs.
2015-05-30 16:08:54 -07:00
Robin Schneider
e361e757da Optimized ovpn_copy_server_files script. No need to copy the config files.
* rsync can copy the actual files.
* This change makes it easier to modifier the configuration and sync it
  to the server. You only have to execute the ovpn_copy_server_files
  once.
2015-05-31 00:52:33 +02:00
Robin Schneider
ca78b46723 Added variable OVPN_ADDITIONAL_CLIENT_CONFIG use arbitrary openvpn configuration options. 2015-05-30 23:03:17 +02:00
Robin Schneider
2e2c66b978 Using better example in docs. 2015-05-30 23:00:53 +02:00
Kyle Manna
5e4bad7bc4 license: Migrate from AGPLv3 -> MIT
* More liberal license
* Closes #43
2015-05-12 12:52:25 -07:00
Robin Schneider
debf45ae46 Changed license of scripts I wrote to MIT. Related to #43. 2015-05-12 21:24:59 +02:00
Kyle Manna
e53492850f crl: Pass crl-verify if found
* Empty CRLs don't work.
* Avoids confusing easyrsa during the init step where it thinks an
  existing PKI configuration exists.
* Add to ovpn_run to help users that are upgrading and ran genconfig
  which now depends on the file being present.
* Use a hardlink to tip toe around permissions issues.
2015-05-12 02:10:43 -07:00
Kyle Manna
978e072d29 docs: Fix typo to CRL steps
* Copy paste error. Oops.
2015-05-11 10:48:09 -07:00
Kyle Manna
5021bad597 ovpn: Add support for revoking certificates (CRL)
* Add this much needed missing feature.  Easy RSA makes it... easy.
2015-05-11 10:41:25 -07:00
Kyle Manna
bcb55f6255 docs: Tweak case and arguments
* Makes the reading more uniform with the rest of the documentation.
2015-05-11 10:32:58 -07:00
Kyle Manna
c3024ce335 genconfig: Remove duplicate-cn mention
* Remove the commented out duplicate-cn configuration option
* Leads to confusion
* Related #42
2015-05-09 15:19:24 -07:00
Kyle Manna
2f9947c8e4 run: Pass cmd line arguments to openvpn
* Pass command line arguments to openvpn if passed in.  Enables users to
  easily override or add settings.
* Resolves #42
2015-05-09 15:18:53 -07:00
Kyle Manna
35c5d7bf70 license: Add AGPLv3 license
* Not sure how I missed this for so long.
2015-03-20 22:32:48 -07:00
Kyle Manna
bf34f341fc Merge remote-tracking branch 'ypid/getclient' into dev 2015-03-20 16:54:22 -07:00
Kyle Manna
a42a42885e Merge pull request #37 from ypid/fix-docs-paranoid
Fix paranoid doc.
2015-03-20 11:49:26 -07:00
Robin Schneider
47cc0e3ae6 Fixed based on the review by @kylemanna. Thanks. 2015-03-14 13:22:28 +01:00
Robin Schneider
06c005a449 Fixed up Markdown. 2015-03-14 13:00:11 +01:00
Robin Schneider
190ab9ae51 Fixed typos. 2015-03-14 12:59:07 +01:00
Kyle Manna
f208847f54 Merge pull request #34 from ypid/master
Wrote script to copy only the needed files to the docker host which runs the docker openvpn server.
2015-03-12 21:03:28 -07:00
Robin Schneider
f431d179aa Fixed spelling. 2015-03-13 02:00:04 +01:00
Robin Schneider
fd4a5dc38e EASYRSA_PKI might not be defined. 2015-03-13 00:43:50 +01:00
Robin Schneider
e6e2221d8b Allow to export separated client config and wrote ovpn_getclient_all. 2015-03-13 00:32:40 +01:00
Robin Schneider
3c64367583 Removed the --dry-run from rsync. Make it actually do something. 2015-03-12 23:49:49 +01:00
Robin Schneider
5e514721ff Added documentation for ovpn_copy_server_files. 2015-03-12 23:11:33 +01:00
Kyle Manna
88c76c787e genconfig: Turn off exit on error at end
* Need to check return status of diff, but don't want a false return
  code to exit the script.
* Fixes #35
2015-03-09 09:19:38 -07:00
Robin Schneider
3d2d839d0b Wrote script to copy only the needed files to the docker host which runs the docker openvpn server.
* For the truly paranoid users, never keep any keys (i.e. client and
  certificate authority) in the docker container to begin with :).
2015-03-08 22:40:08 +01:00
Kyle Manna
8d8f19d951 genconfig: Describe backup conf deletion
* Handle back-up configuration deletion better by informing the user
  why the back-up vanished and why.
* Closes #33
2015-03-07 16:35:08 -08:00
Kyle Manna
96ffed0984 Merge pull request #32 from omriiluz/master
Disable default bash xtrace and fix but in variables
2015-03-01 22:50:35 -08:00
omriiluz
43ae3eb61d properly clone arrays 2015-02-28 03:22:08 -08:00
omriiluz
6b23cf8d88 do not accumulate routes and push directives from default if new directives were defined 2015-02-28 03:01:00 -08:00
omriiluz
e9d1022eb4 Disable bash debug (xtrace) by default, re-enable with -e DEBUG=1 2015-02-28 02:45:31 -08:00
Kyle Manna
42d95bd77a Merge pull request #31 from nuimk/master
Return correct exit status in ovpn_getclient script
2015-02-23 16:52:38 -08:00
Nui Narongwet
e959dca048 Return correct exit status 2015-02-21 02:46:50 +07:00
Kyle Manna
862aa19017 README: Add missing newline
* Fixes rendering issue on Docker Hub.
* If only all the Markdown renders worked the same...
2015-02-10 08:48:28 -08:00
Kyle Manna
5eb8c4b054 docs: Add FAQs document
* Place to put questions rather then the README
2015-02-07 15:10:24 -08:00
Kyle Manna
1940434447 README: Add links to upstream
* Link back to upstream to make it simpler to hop around.
2015-02-07 15:00:19 -08:00
Kyle Manna
4cd6f89a5a README: Add Benefits section
* Write-up the benefits from a comment on the DO tutorial.
2015-02-07 15:00:19 -08:00
Kyle Manna
7f2ae880d5 README: Add link to DO Tutorial
* Add a link to the Digital Ocean tutorial I wrote up some time ago.
2015-02-07 15:00:19 -08:00
Kyle Manna
06aee5bc37 Merge pull request #28 from omriiluz/master
Include optional configuration options
2015-01-17 18:14:35 -08:00
omriiluz
1cb38ce146 Support client mtu push 2015-01-17 01:07:52 -08:00
Omri Iluz
3eeee022fd Create NAT if OVPN_NAT is set (flag -N) 2015-01-17 01:00:18 -08:00
Omri Iluz
1e2418ae37 Control external NAT creation 2015-01-17 00:56:46 -08:00
Omri Iluz
97f231b4e7 Control default DNS push with -D flag 2015-01-17 00:56:21 -08:00
Omri Iluz
bf50da4ee2 Remove hard coded DNS push.
TODO: control with cmdline option
2015-01-16 03:36:47 -08:00
Kyle Manna
f6b177df4e README: Update DO link to $5/mo page
* Update DO link to $5/mo pricing page.  Makes it easier to compare to
  standalone VPN providers.
2015-01-13 14:43:59 -08:00
Kyle Manna
b8de403958 README: Remove port on genconfig line
* The internal port is always 1194 in the container since f1e85c959
* Users wanting to operate on a different public port should change the
  `ovpn_run` line to do the the appropriate thing with `-p` argument.
2015-01-13 14:27:24 -08:00
Jimmy Wong
31a8584685 Run daemon as nobody 2015-01-01 22:57:28 -08:00
Kyle Manna
384beb888a README: Miscellaneous Fixes
* Fix typo and grammar
2015-01-01 22:57:19 -08:00
Kyle Manna
52725702e2 init: Add upstart init file
* Add an Upstart init file to reliably start and stop the container.
2014-12-15 16:01:07 -08:00
Kyle Manna
8cd45f1139 Merge pull request #22 from ZackAdams/master
Fixed SIGTERM handling
2014-12-10 08:22:37 -08:00
Zack Adams
73c206d14a Fixed SIGTERM handling 2014-12-10 10:36:00 -05:00
Kyle Manna
bfb896f716 Merge pull request #21 from flecno/master
no connection block in client config
2014-12-08 13:33:48 -08:00
Timo Zingel
f2148d99ae no connection block in client config 2014-12-08 21:07:46 +01:00
Kyle Manna
473671a4d0 Dockerfile: Shallow clone EasyRSA v3
* Do a shallow clone for a smaller checkout
* Condense multiple run lines to a single RUN line for a flatter image.
2014-12-05 14:07:00 -08:00
Kyle Manna
19f4c5cde4 Dockerfile: Clean-up after apt operations
* Delete old files to keep the image lean.
2014-12-05 13:55:53 -08:00
Kyle Manna
17ef8cebfc docs: advanced: Fix typo
* ... and feed the grammar Nazi
2014-11-16 10:06:04 -08:00
Kyle Manna
f07e4ad531 README: Remove mention of only UDP support
* This was fixed a while ago
  * 9951ca6ca2
* Closes #15
2014-11-16 10:01:59 -08:00
Kyle Manna
656be240b6 README: Add Digital Ocean reference
* Include promo code, because why not?
2014-10-29 08:06:31 -07:00
Kyle Manna
b06631099f Merge pull request #12 from compressed/dup_iptables
avoid dup iptables rules
2014-10-23 09:55:08 -07:00
Christopher Brickley
be22048a2b avoid dup iptables rules 2014-10-23 09:16:51 -04:00
Kyle Manna
f05de3eb84 README: Fix Markdown indent
* Indent to get pre-formatted code box.
2014-10-06 22:34:27 -07:00
Kyle Manna
543292e124 Merge pull request #10 from adrianolek/patch-1
Use --cap-add=NET_ADMIN instead of --privileged
2014-10-06 22:22:30 -07:00
Adrian Olek
8c7d020074 Use --cap-add=NET_ADMIN instead of --privileged
Ovpn doesn't need all the capabilities.
https://docs.docker.com/reference/run/#runtime-privilege-linux-capabilities-and-lxc-configuration says:
For interacting with the network stack, instead of using --privileged they should use --cap-add=NET_ADMIN to modify the network interfaces.
2014-10-06 20:09:23 +02:00
Kyle Manna
a69ca8d65e Merge pull request #8 from disassembler/master
fixing regexp to allow dashes in OVPN_SERVER_URL
2014-08-17 12:53:31 -07:00
Samuel Leathers
f1616f7196 fixing regexp to allow dashes in OVPN_SERVER_URL 2014-08-16 22:32:16 -04:00
Kyle Manna
d36bb7ecba getclient: Do not autogenerate key
* Do not autogenerate a key if it does not exist.  Instead fail.
* Requires users to explicitly generate keys and prevents generating
  erroneous keys in the event of a typo.
2014-07-10 09:55:06 -07:00
Kyle Manna
76a230b3be Merge branch 'docs' 2014-07-09 12:24:30 -07:00
Kyle Manna
5fd47763d7 README: Add --rm to init steps
* Don't need these containers to stick around polluting docker.
2014-07-09 12:23:48 -07:00
Kyle Manna
37f86037d8 advanced: Add advanced configs
* Copy paste stuff for using host mounted volumes
2014-07-09 12:21:50 -07:00
Kyle Manna
e9c5108a8f debug: Add mention of shells
* Very useful for getting in a running container or fix a data volume.
2014-07-09 12:21:38 -07:00
Kyle Manna
816eff9af6 docs: openvpn-data -> $OVPN_DATA
* Easier to work with.
2014-07-09 12:09:27 -07:00
Kyle Manna
c38b412dc6 Merge branch 'private_subnet'
Closes #5
2014-07-09 11:10:54 -07:00
Kyle Manna
b9cc5b347a genconfig: Convert OVPN_ROUTES to array
* Convert to an array to simplify the code.
* This breaks running `ovpn_genconfig` multiple times with the same
  route argument as the array will just grow.  This needs to be fixed in
  the future.
* Recommended way to work around this is to remove ovpn_env.sh.
2014-07-09 11:06:02 -07:00
Kyle Manna
20be0f90a5 genconfig: Add push support
* Add ability to specify push commands with `-p` argument.
2014-07-09 10:55:02 -07:00
Kyle Manna
0c873ab4cf genconfig: Print success
* Print success message to console. Provides positive feedback.
2014-07-09 10:53:41 -07:00
Kyle Manna
f263eb9a61 genconfig: Add client-to-client support 2014-07-09 10:53:25 -07:00
Kyle Manna
d5979915cf README: Use variable for volume container name
* Use a variable for the volume container name to simplify my life.
* I can set the variable and then copy/paste from the README.
2014-07-09 00:07:35 -07:00
25 changed files with 1195 additions and 451 deletions

33
.travis.yml Normal file
View File

@@ -0,0 +1,33 @@
# Disallowing packages: openvpn
# If you require these packages, please review the package approval process at: https://github.com/travis-ci/apt-package-whitelist#package-approval-process
#addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - openvpn
services:
- docker
before_install:
- docker --version
install:
- git clone https://github.com/docker-library/official-images.git official-images
# Assist with ci test debugging:
# - DEBUG=1
before_script:
- image="kylemanna/openvpn"
- docker build -t "$image" .
- docker inspect "$image"
- docker run --rm "$image" openvpn --version || true # why does it return 1?
- docker run --rm "$image" openssl version
script:
- official-images/test/run.sh "$image"
- test/run.sh "$image"
after_script:
- docker images

View File

@@ -1,30 +0,0 @@
# Original credit: https://github.com/jpetazzo/dockvpn
# Leaner build then Ubunutu
FROM debian:jessie
MAINTAINER Kyle Manna <kyle@kylemanna.com>
RUN apt-get update && apt-get install -y openvpn iptables git-core
# Update checkout to use tags when v3.0 is finally released
RUN git clone https://github.com/OpenVPN/easy-rsa.git /usr/local/share/easy-rsa
RUN cd /usr/local/share/easy-rsa && git checkout -b tested 89f369c5bbd13fbf0da2ea6361632c244e8af532
RUN ln -s /usr/local/share/easy-rsa/easyrsa3/easyrsa /usr/local/bin
# Needed by scripts
ENV OPENVPN /etc/openvpn
ENV EASYRSA /usr/local/share/easy-rsa/easyrsa3
ENV EASYRSA_PKI $OPENVPN/pki
ENV EASYRSA_VARS_FILE $OPENVPN/vars
VOLUME ["/etc/openvpn"]
# Internally uses port 1194, remap using docker
EXPOSE 1194/udp
WORKDIR /etc/openvpn
CMD ["ovpn_run"]
ADD ./bin /usr/local/bin
RUN chmod a+x /usr/local/bin/*

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Kyle Manna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

230
README.md
View File

@@ -1,120 +1,152 @@
# OpenVPN for Docker OpenVPN for Docker-compose
============================
OpenVPN server in a Docker container complete with an EasyRSA PKI CA. OpenVPN server in a Docker container complete with an EasyRSA PKI CA.
## Quick Start Check if your port is availlable
================================
* Create the `openvpn-data` volume container On your server:
```{.sh}
nc -ul -p 1194
```
docker run --name openvpn-data -v /etc/openvpn busybox On your computer
```{.sh}
* Initalize the `openvpn-data` container that will hold the configuration files and certificates nc -u __SERVER_IP__ 1194
```
docker run --volumes-from openvpn-data kylemanna/openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM:1194
docker run --volumes-from openvpn-data -it kylemanna/openvpn ovpn_initpki
* Start OpenVPN server process
docker run --volumes-from openvpn-data -d -p 1194:1194/udp --privileged kylemanna/openvpn
* Generate a client certificate without a passphrase
docker run --volumes-from openvpn-data --rm -it kylemanna/openvpn easyrsa build-client-full CLIENTNAME nopass
* Retrieve the client configuration with embedded certificates
docker run --volumes-from openvpn-data --rm kylemanna/openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn
## How Does It Work? Remove other VPN local:
Initialize the volume container using the `kylemanna/openvpn` image with the In case an other service is started :
included scripts to automatically generate: ```
sudo systemctl stop openvpn@server.service
- Diffie-Hellman parameters ```
- a private key
- a self-certificate matching the private key for the OpenVPN server
- an EasyRSA CA key and certificate
- a TLS auth key from HMAC security
The OpenVPN server is started with the default run cmd of `ovpn_run`
The configuration is located in `/etc/openvpn`, and the Dockerfile
declares that directory as a volume. It means that you can start another
container with the `--volumes-from` flag, and access the configuration.
The volume also holds the PKI keys and certs so that it could be backed up.
To generate a client certificate, `kylemanna/openvpn` uses EasyRSA via the
`easyrsa` command in the container's path. The `EASYRSA_*` environmental
variables place the PKI CA under `/etc/opevpn/pki`.
Conveniently, `kylemanna/openvpn` comes with a script called `ovpn_getclient`,
which dumps an inline OpenVPN client configuration file. This single file can
then be given to a client for access to the VPN.
## OpenVPN Details Quick Start with docker-compose
================================
We use `tun` mode, because it works on the widest range of devices. ```{.sh}
`tap` mode, for instance, does not work on Android, except if the device docker-compose run --rm openvpn_service ovpn_genconfig -u udp://____VPN.SERVERNAME.COM____
is rooted. docker-compose run --rm openvpn_service ovpn_initpki
```
The topology used is `net30`, because it works on the widest range of OS. or
`p2p`, for instance, does not work on Windows.
The UDP server uses`192.168.255.0/24` for dynamic clients by default. ```{.sh}
docker-compose run --rm openvpn_service ovpn_genconfig -u udp://____VPN.SERVERNAME.COM____ -b -D -C AES-256-CBC -p ____LOCAL_IP_SERVER____/32 -R -V -F
docker-compose run --rm openvpn_service ovpn_initpki
```
The client profile specifies `redirect-gateway def1`, meaning that after **Note:** the ```-d``` create some errors
establishing the VPN connection, all traffic will go through the VPN.
This might cause problems if you use local DNS recursors which are not
directly reachable, since you will try to reach them through the VPN
and they might not answer to you. If that happens, use public DNS
resolvers like those of Google (8.8.4.4 and 8.8.8.8) or OpenDNS
(208.67.222.222 and 208.67.220.220).
## Security Discussion With a teltonika routeur, you need to add the interface of the docker:
```
The Docker container runs its own EasyRSA PKI Certificate Authority. This was -p "route 10.3.1.0 255.255.255.0"
chosen as a good way to compromise on security and convenience. The container ```
runs under the assumption that the OpenVPN container is running on a secure
host, that is to say that an adversary does not have access to the PKI files
under `/etc/openvpn/pki`. This is a fairly reasonable compromise because if an
adversary had access to these files, the adversary could manipulate the
function of the OpenVPN server itself (sniff packets, create a new PKI CA, MITM
packets, etc).
* The certificate authority key is kept in the container by default for
simplicity. It's highly recommended to secure the CA key with some
passphrase to protect against a filesystem compromise. A more secure system
would put the EasyRSA PKI CA on an offline system (can use the same Docker
image to accomplish this).
* It would be impossible for an adversary to sign bad or forged certificates
without first cracking the key's passphase should the adversary have root
access to the filesystem.
* The EasyRSA `build-client-full` command will generate and leave keys on the
server, again possible to compromise and steal the keys. The keys generated
need to signed by the CA which the user hopefully configured with a passphrase
as described above.
* Assuming the rest of the Docker container's filesystem is secure, TLS + PKI
security should prevent any malicious host from using the VPN.
## Differences from jpetazzo/dockvpn
* No longer uses serveconfig to distribute the configuration via https Fix ownership (depending on how to handle your backups, this may not be needed)
* Proper PKI support integrated into image ---------------------------------------------------------------------------------
* OpenVPN config files, PKI keys and certs are stored on a storage
volume for re-use across containers
* Only offer UDP support for now, I don't have a good use case for TCP
* Addition of tls-auth for HMAC security
## Tested On ```{.sh}
sudo chown -R $(whoami): ./openvpn-data
```
Start OpenVPN server process
----------------------------
```{.sh}
docker-compose up -d openvpn_service
```
You can access the container logs with
--------------------------------------
```{.sh}
docker-compose logs -f
```
Generate a client certificate
-----------------------------
```{.sh}
export CLIENT_NAME="your_client_name"
# with a passphrase (recommended)
docker-compose run --rm openvpn easyrsa build-client-full $CLIENT_NAME
# without a passphrase (not recommended)
docker-compose run --rm openvpn easyrsa build-client-full $CLIENT_NAME nopass
```
Add toute too the client:
```
echo "route 10.10.1.0 255.255.255.0" >> openvpn-data/conf/openvpn.conf
echo "iroute 10.10.1.0 255.255.255.0" > openvpn-data/conf/ccd/$CLIENT_NAME
```
Retrieve the client configuration with embedded certificates
------------------------------------------------------------
In a single file:
```{.sh}
# if the container is down
docker-compose run --rm openvpn_service ovpn_getclient $CLIENT_NAME > $CLIENT_NAME.ovpn
# if the container is up
docker-compose exec openvpn_service ovpn_getclient $CLIENT_NAME > $CLIENT_NAME.ovpn
```
In multiple files
```{.sh}
# if the container is down
docker-compose run --rm openvpn_service ovpn_getclient $CLIENT_NAME separated
# if the container is up
docker-compose exec openvpn_service ovpn_getclient $CLIENT_NAME separated
```
Revoke a client certificate
---------------------------
```{.sh}
# Keep the corresponding crt, key and req files.
docker-compose run --rm openvpn_service ovpn_revokeclient $CLIENT_NAME
# Remove the corresponding crt, key and req files.
docker-compose run --rm openvpn_service ovpn_revokeclient $CLIENT_NAME remove
```
Debugging Tips
--------------
* Create an environment variable with the name DEBUG and value of 1 to enable debug output (using "docker -e").
```{.sh}
docker-compose run -e DEBUG=1 -p 1194:1194/udp openvpn_service
```
Test on the client:
-------------------
Run in root mode:
```
openvpn --config $CLIENT_NAME.ovpn
```
you can test the connection with the server:
```
ping ____LOCAL_IP_SERVER____
```
On server test the Connectionwith the client:
```
ping ____CLIENT_IP_SERVER____
```
If needed add the routing rules on the server:
```
ip route add 10.10.0.0/16 via 10.3.0.2
```
* Docker hosts:
* server a Digitial Ocean Droplet with 512 MB RAM running Ubuntu 14.04
* Clients
* Android App OpenVPN Connect 1.1.14 (built 56)
* OpenVPN core 3.0 android armv7a thumb2 32-bit
* OS X Mavericks with Tunnelblick 3.4beta26 (build 3828) using openvpn-2.3.4
* ArchLinux OpenVPN pkg 2.3.4-1

View File

@@ -1,167 +0,0 @@
#!/bin/bash
#
# Generate OpenVPN configs
#
# Convert 1.2.3.4/24 -> 255.255.255.0
cidr2mask()
{
local i
local subnetmask=""
local cidr=${1#*/}
local full_octets=$(($cidr/8))
local partial_octet=$(($cidr%8))
for ((i=0;i<4;i+=1)); do
if [ $i -lt $full_octets ]; then
subnetmask+=255
elif [ $i -eq $full_octets ]; then
subnetmask+=$((256 - 2**(8-$partial_octet)))
else
subnetmask+=0
fi
[ $i -lt 3 ] && subnetmask+=.
done
echo $subnetmask
}
# Used often enough to justify a function
getroute() {
echo ${1%/*} $(cidr2mask $1)
}
usage() {
echo "usage: $0 [-d]"
echo " -u SERVER_PUBLIC_URL"
echo " [-s SERVER_SUBNET]"
echo " [-r ROUTE ...]"
echo
echo "optional arguments:"
echo " -d Disable NAT routing and default route"
}
set -ex
OVPN_ENV=$OPENVPN/ovpn_env.sh
OVPN_SERVER=192.168.255.0/24
OVPN_DEFROUTE=1
# Import defaults if present
[ -r "$OVPN_ENV" ] && source "$OVPN_ENV"
ORIG_OVPN_ROUTES=$OVPN_ROUTES
OVPN_ROUTES=""
# Parse arguments
while getopts ":r:s:du:" opt; do
case $opt in
r)
if [ -n "$OVPN_ROUTES" ]; then
OVPN_ROUTES+=" $OPTARG"
else
OVPN_ROUTES+="$OPTARG"
fi
;;
s)
OVPN_SERVER=$OPTARG
;;
d)
OVPN_DEFROUTE=0
;;
u)
OVPN_SERVER_URL=$OPTARG
;;
\?)
set +x
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
:)
set +x
echo "Option -$OPTARG requires an argument." >&2
usage
exit 1
;;
esac
done
# Server name is in the form "udp://vpn.example.com:1194"
if [[ "$OVPN_SERVER_URL" =~ ^((udp|tcp)://)?([0-9a-zA-Z\.]+)(:([0-9]+))?$ ]]; then
OVPN_PROTO=${BASH_REMATCH[2]};
OVPN_CN=${BASH_REMATCH[3]};
OVPN_PORT=${BASH_REMATCH[5]};
else
set +x
echo "Common name not specified, see '-u'"
usage
exit 1
fi
# Apply defaults
[ -z "$OVPN_PROTO" ] && OVPN_PROTO=udp
[ -z "$OVPN_PORT" ] && OVPN_PORT=1194
if [ -z "$OVPN_ROUTES" ]; then
if [ -n "$ORIG_OVPN_ROUTES" ]; then
OVPN_ROUTES=$ORIG_OVPN_ROUTES
else
OVPN_ROUTES=192.168.254.0/24
fi
fi
export OVPN_SERVER OVPN_ROUTES OVPN_DEFROUTE
export OVPN_SERVER_URL OVPN_ENV OVPN_PROTO OVPN_CN OVPN_PORT
# Preserve config
if [ -f "$OVPN_ENV" ]; then
bak_env=$OVPN_ENV.$(date +%s).bak
echo "Backing up $OVPN_ENV -> $bak_env"
mv "$OVPN_ENV" "$bak_env"
fi
export | grep OVPN_ > "$OVPN_ENV"
conf=$OPENVPN/openvpn.conf
if [ -f "$conf" ]; then
bak=$conf.$(date +%s).bak
echo "Backing up $conf -> $bak"
mv "$conf" "$bak"
fi
cat > "$conf" <<EOF
server $(getroute $OVPN_SERVER)
verb 3
#duplicate-cn
key $EASYRSA_PKI/private/${OVPN_CN}.key
ca $EASYRSA_PKI/ca.crt
cert $EASYRSA_PKI/issued/${OVPN_CN}.crt
dh $EASYRSA_PKI/dh.pem
tls-auth $EASYRSA_PKI/ta.key
key-direction 0
keepalive 10 60
persist-key
persist-tun
push "dhcp-option DNS 8.8.4.4"
push "dhcp-option DNS 8.8.8.8"
proto $OVPN_PROTO
# Rely on Docker to do port mapping, internally always 1194
port 1194
dev tun0
status /tmp/openvpn-status.log
client-config-dir $OPENVPN/ccd
EOF
# Append Routes
for i in ${OVPN_ROUTES[@]}; do
# If user passed "0" skip this, assume no extra routes
[ "$i" = "0" ] && break;
echo route $(getroute $i) >> "$conf"
done
# Clean-up duplicate configs (always return success)
diff -q "$bak_env" "$OVPN_ENV" 2> /dev/null && rm "$bak_env" || true
diff -q "$bak" "$conf" 2> /dev/null && rm "$bak" || true

View File

@@ -1,46 +0,0 @@
#!/bin/bash
#
# Get an OpenVPN client configuration file
#
set -ex
source "$OPENVPN/ovpn_env.sh"
cn=$1
if [ ! -f "$EASYRSA_PKI/private/${cn}.key" ]; then
easyrsa build-server-full $cn nopass
fi
cat <<EOF
client
nobind
dev tun
remote-cert-tls server
<key>
$(cat $EASYRSA_PKI/private/${cn}.key)
</key>
<cert>
$(cat $EASYRSA_PKI/issued/${cn}.crt)
</cert>
<ca>
$(cat $EASYRSA_PKI/ca.crt)
</ca>
<dh>
$(cat $EASYRSA_PKI/dh.pem)
</dh>
<tls-auth>
$(cat $EASYRSA_PKI/ta.key)
</tls-auth>
key-direction 1
<connection>
remote $OVPN_CN $OVPN_PORT $OVPN_PROTO
</connection>
EOF
if [ "$OVPN_DEFROUTE" != "0" ];then
echo "redirect-gateway def1"
fi

View File

@@ -1,31 +0,0 @@
#!/bin/bash
#
# Run the OpenVPN server normally
#
set -ex
source "$OPENVPN/ovpn_env.sh"
mkdir -p /dev/net
if [ ! -c /dev/net/tun ]; then
mknod /dev/net/tun c 10 200
fi
if [ ! -d "$OPENVPN/ccd" ]; then
mkdir -p /etc/openvpn/ccd
fi
# Setup NAT forwarding if requested
if [ "$OVPN_DEFROUTE" != "0" ];then
iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o eth0 -j MASQUERADE
for i in ${OVPN_ROUTES[@]}; do
iptables -t nat -A POSTROUTING -s $i -o eth0 -j MASQUERADE
done
fi
conf="$OPENVPN/openvpn.conf"
openvpn --config "$conf"

20
docker-compose.yaml Normal file
View File

@@ -0,0 +1,20 @@
version: '3'
services:
openvpn_service:
privileged: true
cap_add:
- NET_ADMIN
build: docker
container_name: openvpn
ports:
- "1194:1194/udp"
restart: always
volumes:
- ./openvpn-data/conf:/etc/openvpn
networks:
default:
ipam:
driver: default
config:
- subnet: 10.3.1.0/30

View File

@@ -0,0 +1,2 @@
# Enable network forwarding
net.ipv4.ip_forward=1

37
docker/Dockerfile Normal file
View File

@@ -0,0 +1,37 @@
# Original credit: https://github.com/jpetazzo/dockvpn
# Smallest base image
FROM alpine:latest
LABEL maintainer="Edouard DUPIN <yui.heero@gmail.com>"
# Testing: pamtester
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories && \
apk add --update openvpn iptables bash easy-rsa openvpn-auth-pam google-authenticator pamtester && \
ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*
# Needed by scripts
ENV OPENVPN /etc/openvpn
ENV EASYRSA /usr/share/easy-rsa
ENV EASYRSA_PKI $OPENVPN/pki
ENV EASYRSA_VARS_FILE $OPENVPN/vars
# Prevents refused client connection because of an expired CRL
ENV EASYRSA_CRL_DAYS 3650
VOLUME ["/etc/openvpn"]
# Internally uses port 1194/udp, remap using `docker run -p 443:1194/tcp`
EXPOSE 1194/udp
CMD ["ovpn_run"]
ADD ./11_route_enable.conf /etc/sysctl.d/11_route_enable.conf
RUN sysctl -p /etc/sysctl.d/*
ADD ./bin /usr/local/bin
RUN chmod a+x /usr/local/bin/*
# Add support for OTP authentication using a PAM module
ADD ./otp/openvpn /etc/pam.d/

View File

@@ -4,7 +4,11 @@
# Import/export EasyRSA default settings # Import/export EasyRSA default settings
# #
set -ex if [ "$DEBUG" == "1" ]; then
set -x
fi
set -e
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
echo "No command provided" echo "No command provided"

View File

@@ -0,0 +1,47 @@
#!/bin/bash
## @licence MIT <http://opensource.org/licenses/MIT>
## @author Copyright (C) 2015 Robin Schneider <ypid@riseup.net>
set -e
if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD"
fi
if ! source "$OPENVPN/ovpn_env.sh"; then
echo "Could not source $OPENVPN/ovpn_env.sh."
exit 1
fi
TARGET="$OPENVPN/server"
if [ -n "$1" ]; then
TARGET="$1"
fi
mkdir -p "${TARGET}"
## Ensure that no other keys then the one for the server is present.
rm -rf "$TARGET/pki/private" "$TARGET/pki/issued"
FILES=(
"openvpn.conf"
"ovpn_env.sh"
"pki/private/${OVPN_CN}.key"
"pki/issued/${OVPN_CN}.crt"
"pki/dh.pem"
"pki/ta.key"
"pki/ca.crt"
"ccd"
)
if [ -f "${OPENVPN}/pki/crl.pem" ]; then
FILES+=("pki/crl.pem")
fi
# Ensure the ccd directory exists, even if empty
mkdir -p "ccd"
# rsync isn't available to keep size down
# cp --parents isn't in busybox version
# hack the directory structure with tar
tar cf - -C "${OPENVPN}" "${FILES[@]}" | tar xvf - -C "${TARGET}"
echo "Created the openvpn configuration for the server: $TARGET"

467
docker/bin/ovpn_genconfig Executable file
View File

@@ -0,0 +1,467 @@
#!/bin/bash
#
# Generate OpenVPN configs
#
TMP_PUSH_CONFIGFILE=$(mktemp -t vpn_push.XXXXXXX)
TMP_ROUTE_CONFIGFILE=$(mktemp -t vpn_route.XXXXXXX)
TMP_EXTRA_CONFIGFILE=$(mktemp -t vpn_extra.XXXXXXX)
#Traceback on Error and Exit come from https://docwhat.org/tracebacks-in-bash/
set -eu
_showed_traceback=f
traceback() {
# Hide the traceback() call.
local -i start=$(( ${1:-0} + 1 ))
local -i end=${#BASH_SOURCE[@]}
local -i i=0
local -i j=0
echo "Traceback (last called is first):" 1>&2
for ((i=${start}; i < ${end}; i++)); do
j=$(( $i - 1 ))
local function="${FUNCNAME[$i]}"
local file="${BASH_SOURCE[$i]}"
local line="${BASH_LINENO[$j]}"
echo " ${function}() in ${file}:${line}" 1>&2
done
}
on_error() {
local _ec="$?"
local _cmd="${BASH_COMMAND:-unknown}"
traceback 1
_showed_traceback=t
echo "The command ${_cmd} exited with exit code ${_ec}." 1>&2
}
trap on_error ERR
on_exit() {
echo "Cleaning up before Exit ..."
rm -f $TMP_PUSH_CONFIGFILE
rm -f $TMP_ROUTE_CONFIGFILE
rm -f $TMP_EXTRA_CONFIGFILE
local _ec="$?"
if [[ $_ec != 0 && "${_showed_traceback}" != t ]]; then
traceback 1
fi
}
trap on_exit EXIT
# Convert 1.2.3.4/24 -> 255.255.255.0
cidr2mask()
{
local i
local subnetmask=""
local cidr=${1#*/}
local full_octets=$(($cidr/8))
local partial_octet=$(($cidr%8))
for ((i=0;i<4;i+=1)); do
if [ $i -lt $full_octets ]; then
subnetmask+=255
elif [ $i -eq $full_octets ]; then
subnetmask+=$((256 - 2**(8-$partial_octet)))
else
subnetmask+=0
fi
[ $i -lt 3 ] && subnetmask+=.
done
echo $subnetmask
}
# Used often enough to justify a function
getroute() {
echo ${1%/*} $(cidr2mask $1)
}
usage() {
echo "usage: $0 [-d]"
echo " -u SERVER_PUBLIC_URL"
echo " [-e EXTRA_SERVER_CONFIG ]"
echo " [-E EXTRA_CLIENT_CONFIG ]"
echo " [-f FRAGMENT ]"
echo " [-n DNS_SERVER ...]"
echo " [-p PUSH ...]"
echo " [-r ROUTE ...]"
echo " [-s SERVER_SUBNET]"
echo
echo "optional arguments:"
echo " -2 Enable two factor authentication using Google Authenticator."
echo " -a Authenticate packets with HMAC using the given message digest algorithm (auth)."
echo " -b Disable 'push block-outside-dns'"
echo " -c Enable client-to-client option"
echo " -C A list of allowable TLS ciphers delimited by a colon (cipher)."
echo " -d Disable default route"
echo " -D Do not push dns servers"
echo " -k Set keepalive. Default: '10 120'"
echo " -m Set client MTU"
echo " -N Configure NAT to access external server network"
echo " -t Use TAP device (instead of TUN device)"
echo " -T Encrypt packets with the given cipher algorithm instead of the default one (tls-cipher)."
echo " -z Enable comp-lzo compression."
echo " -S Change status folder. Default '/tmp'."
echo " -R Disable the reduce the OpenVPN daemon's privileges after initialization."
echo " -K Set a client config directory. Default Disable. Example: 'ccd'."
echo " -V Enable the the record of client <-> virtual IP address (store in a config file)."
echo " -L Configure log mode: 'disable', 'enable', 'append'. Default 'disable'."
echo " -F Enable the notification to the client that the server restarts."
}
process_route_config() {
local ovpn_route_config=''
ovpn_route_config="$1"
# If user passed "0" skip this, assume no extra routes
[[ "$ovpn_route_config" == "0" ]] && break;
echo "Processing Route Config: '${ovpn_route_config}'"
[[ -n "$ovpn_route_config" ]] && echo "route $(getroute $ovpn_route_config)" >> "$TMP_ROUTE_CONFIGFILE"
}
process_push_config() {
local ovpn_push_config=''
ovpn_push_config="$1"
echo "Processing PUSH Config: '${ovpn_push_config}'"
[[ -n "$ovpn_push_config" ]] && echo "push \"$ovpn_push_config\"" >> "$TMP_PUSH_CONFIGFILE"
}
process_extra_config() {
local ovpn_extra_config=''
ovpn_extra_config="$1"
echo "Processing Extra Config: '${ovpn_extra_config}'"
[[ -n "$ovpn_extra_config" ]] && echo "$ovpn_extra_config" >> "$TMP_EXTRA_CONFIGFILE"
}
if [ "${DEBUG:-}" == "1" ]; then
set -x
fi
set -e
if [ -z "${OPENVPN:-}" ]; then
export OPENVPN="$PWD"
fi
if [ -z "${EASYRSA_PKI:-}" ]; then
export EASYRSA_PKI="$OPENVPN/pki"
fi
OVPN_AUTH=''
OVPN_CIPHER=''
OVPN_CLIENT_TO_CLIENT=''
OVPN_CN=''
OVPN_COMP_LZO=0
OVPN_DEFROUTE=1
OVPN_DEVICE="tun"
OVPN_DEVICEN=0
OVPN_DISABLE_PUSH_BLOCK_DNS=0
OVPN_DNS=1
OVPN_DNS_SERVERS=()
OVPN_ENV=${OPENVPN}/ovpn_env.sh
OVPN_EXTRA_CLIENT_CONFIG=()
OVPN_EXTRA_SERVER_CONFIG=()
OVPN_FRAGMENT=''
OVPN_KEEPALIVE="10 120"
OVPN_MTU=''
OVPN_NAT=0
OVPN_PORT=''
OVPN_PROTO=''
OVPN_PUSH=()
OVPN_ROUTES=()
OVPN_SERVER=192.168.200.0/24
OVPN_SERVER_URL=''
OVPN_TLS_CIPHER=''
OVPN_STATUS_PATH='/tmp'
OVPN_DISABLE_REDUCE_DEAMON_S_PRIVILEGES=0
OVPN_CLIENT_CONFIG_DIR=''
OVPN_ENABLE_KEEP_CLIENT_VIRTUAL_IP=0
OVPN_LOG_MODE="disable"
OVPN_ENABLE_NOTIFY_SERVER_RESTARTS=0
# Import existing configuration if present
[ -r "$OVPN_ENV" ] && source "$OVPN_ENV"
# Parse arguments
while getopts ":a:e:E:C:T:r:s:du:bcp:n:k:DNm:f:tz2S:RK:VL:F" opt; do
case $opt in
a)
OVPN_AUTH="$OPTARG"
;;
e)
mapfile -t TMP_EXTRA_SERVER_CONFIG <<< "$OPTARG"
for i in "${TMP_EXTRA_SERVER_CONFIG[@]}"; do
OVPN_EXTRA_SERVER_CONFIG+=("$i")
done
;;
E)
mapfile -t TMP_EXTRA_CLIENT_CONFIG <<< "$OPTARG"
for i in "${TMP_EXTRA_CLIENT_CONFIG[@]}"; do
OVPN_EXTRA_CLIENT_CONFIG+=("$i")
done
;;
C)
OVPN_CIPHER="$OPTARG"
;;
T)
OVPN_TLS_CIPHER="$OPTARG"
;;
r)
mapfile -t TMP_ROUTES <<< "$OPTARG"
for i in "${TMP_ROUTES[@]}"; do
OVPN_ROUTES+=("$i")
done
;;
s)
OVPN_SERVER="$OPTARG"
;;
d)
OVPN_DEFROUTE=0
OVPN_DISABLE_PUSH_BLOCK_DNS=1
;;
u)
OVPN_SERVER_URL="$OPTARG"
;;
b)
OVPN_DISABLE_PUSH_BLOCK_DNS=1
;;
c)
OVPN_CLIENT_TO_CLIENT=1
;;
p)
mapfile -t TMP_PUSH <<< "$OPTARG"
for i in "${TMP_PUSH[@]}"; do
OVPN_PUSH+=("$i")
done
;;
n)
mapfile -t TMP_DNS_SERVERS <<< "$OPTARG"
for i in "${TMP_DNS_SERVERS[@]}"; do
OVPN_DNS_SERVERS+=("$i")
done
;;
D)
OVPN_DNS=0
;;
N)
OVPN_NAT=1
;;
k)
OVPN_KEEPALIVE="$OPTARG"
;;
m)
OVPN_MTU="$OPTARG"
;;
t)
OVPN_DEVICE="tap"
;;
z)
OVPN_COMP_LZO=1
;;
2)
OVPN_OTP_AUTH=1
;;
f)
OVPN_FRAGMENT="$OPTARG"
;;
S)
OVPN_STATUS_PATH="$OPTARG"
;;
R)
OVPN_DISABLE_REDUCE_DEAMON_S_PRIVILEGES=1
;;
K)
OVPN_CLIENT_CONFIG_DIR="$OPTARG"
;;
V)
OVPN_ENABLE_KEEP_CLIENT_VIRTUAL_IP=1
;;
L)
OVPN_LOG_MODE="$OPTARG"
;;
F)
OVPN_ENABLE_NOTIFY_SERVER_RESTARTS=1
;;
\?)
set +x
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
:)
set +x
echo "Option -$OPTARG requires an argument." >&2
usage
exit 1
;;
esac
done
# Create ccd directory for static routes
[ ! -d "${OPENVPN:-}/ccd" ] && mkdir -p ${OPENVPN:-}/ccd
# Server name is in the form "udp://vpn.example.com:1194"
if [[ "${OVPN_SERVER_URL:-}" =~ ^((udp|tcp|udp6|tcp6)://)?([0-9a-zA-Z\.\-]+)(:([0-9]+))?$ ]]; then
OVPN_PROTO=${BASH_REMATCH[2]};
OVPN_CN=${BASH_REMATCH[3]};
OVPN_PORT=${BASH_REMATCH[5]};
else
set +x
echo "Common name not specified, see '-u'"
usage
exit 1
fi
# Apply defaults. If dns servers were not defined with -n, use google nameservers
set +u
[ -z "$OVPN_DNS_SERVERS" ] && OVPN_DNS_SERVERS=("8.8.8.8" "8.8.4.4")
[ -z "$OVPN_PROTO" ] && OVPN_PROTO=udp
[ -z "$OVPN_PORT" ] && OVPN_PORT=1194
set -u
[ "${#OVPN_ROUTES[@]}" == "0" ] && [ "$OVPN_DEFROUTE" == "1" ] && OVPN_ROUTES+=("192.168.200.0/24")
# Preserve config
if [ -f "$OVPN_ENV" ]; then
bak_env=$OVPN_ENV.$(date +%s).bak
echo "Backing up $OVPN_ENV -> $bak_env"
mv "$OVPN_ENV" "$bak_env"
fi
# Save the current OVPN_ vars to the ovpn_env.sh file
(set | grep '^OVPN_') | while read -r var; do
echo "declare -x $var" >> "$OVPN_ENV"
done
conf=${OPENVPN:-}/openvpn.conf
if [ -f "$conf" ]; then
bak=$conf.$(date +%s).bak
echo "Backing up $conf -> $bak"
mv "$conf" "$bak"
fi
# Echo extra client configurations
if [ ${#OVPN_EXTRA_CLIENT_CONFIG[@]} -gt 0 ]; then
for i in "${OVPN_EXTRA_CLIENT_CONFIG[@]}"; do
echo "Processing Extra Client Config: $i"
done
fi
cat > "$conf" <<EOF
server $(getroute $OVPN_SERVER)
verb 3
key $EASYRSA_PKI/private/${OVPN_CN}.key
ca $EASYRSA_PKI/ca.crt
cert $EASYRSA_PKI/issued/${OVPN_CN}.crt
dh $EASYRSA_PKI/dh.pem
tls-auth $EASYRSA_PKI/ta.key
key-direction 0
keepalive $OVPN_KEEPALIVE
persist-key
persist-tun
proto $OVPN_PROTO
# Rely on Docker to do port mapping, internally always 1194
port 1194
dev $OVPN_DEVICE$OVPN_DEVICEN
status $OVPN_STATUS_PATH/openvpn-status.log
EOF
if [ "${OVPN_DISABLE_REDUCE_DEAMON_S_PRIVILEGES}" == "1" ]; then
echo "Disable 'user' and 'group'"
else
echo "user nobody" >> "$conf"
echo "group nogroup" >> "$conf"
fi
if [ "${OVPN_DISABLE_PUSH_BLOCK_DNS}" == "1" ]; then
echo "Disable default push of 'block-outside-dns'"
else
process_push_config "block-outside-dns"
fi
if [ "${OVPN_CLIENT_CONFIG_DIR}" == "" ]; then
echo "Disable client config 'client-config-dir'"
else
echo "client-config-dir ${OVPN_CLIENT_CONFIG_DIR}" >> "$conf"
fi
[ -n "$OVPN_TLS_CIPHER" ] && echo "tls-cipher $OVPN_TLS_CIPHER" >> "$conf"
[ -n "$OVPN_CIPHER" ] && echo "cipher $OVPN_CIPHER" >> "$conf"
[ -n "$OVPN_AUTH" ] && echo "auth $OVPN_AUTH" >> "$conf"
[ -n "${OVPN_CLIENT_TO_CLIENT:-}" ] && echo "client-to-client" >> "$conf"
[ "$OVPN_COMP_LZO" == "1" ] && echo "comp-lzo" >> "$conf"
[ "$OVPN_COMP_LZO" == "0" ] && echo "comp-lzo no" >> "$conf"
[ "$OVPN_ENABLE_KEEP_CLIENT_VIRTUAL_IP" == "1" ] && echo "ifconfig-pool-persist /etc/openvpn/client_vitual_ip.txt" >> "$conf"
[ "$OVPN_ENABLE_NOTIFY_SERVER_RESTARTS" == "1" ] && echo "explicit-exit-notify 1" >> "$conf"
if [ "${OVPN_LOG_MODE}" == "enable" ]; then
echo "log /var/log/openvpn/openvpn.log" >> "$conf"
else
if [ "${OVPN_LOG_MODE}" == "append" ]; then
echo "log-append /var/log/openvpn/openvpn.log" >> "$conf"
else
echo "Log file mode is disable"
fi
fi
[ -n "${OVPN_FRAGMENT:-}" ] && echo "fragment $OVPN_FRAGMENT" >> "$conf"
# Append route commands
if [ ${#OVPN_ROUTES[@]} -gt 0 ]; then
for i in "${OVPN_ROUTES[@]}"; do
process_route_config "$i"
done
echo -e "\n### Route Configurations Below" >> "$conf"
cat $TMP_ROUTE_CONFIGFILE >> "$conf"
fi
# Append push commands
[ "$OVPN_DNS" == "1" ] && for i in "${OVPN_DNS_SERVERS[@]}"; do
process_push_config "dhcp-option DNS $i"
done
if [ "$OVPN_COMP_LZO" == "0" ]; then
process_push_config "comp-lzo no"
fi
[ ${#OVPN_PUSH[@]} -gt 0 ] && for i in "${OVPN_PUSH[@]}"; do
process_push_config "$i"
done
echo -e "\n### Push Configurations Below" >> "$conf"
cat $TMP_PUSH_CONFIGFILE >> "$conf"
# Append optional OTP authentication support
if [ -n "${OVPN_OTP_AUTH:-}" ]; then
echo -e "\n\n# Enable OTP+PAM for user authentication" >> "$conf"
echo "plugin /usr/lib/openvpn/plugins/openvpn-plugin-auth-pam.so openvpn" >> "$conf"
echo "reneg-sec 0" >> "$conf"
fi
# Append extra server configurations
if [ ${#OVPN_EXTRA_SERVER_CONFIG[@]} -gt 0 ]; then
for i in "${OVPN_EXTRA_SERVER_CONFIG[@]}"; do
process_extra_config "$i"
done
echo -e "\n### Extra Configurations Below" >> "$conf"
cat $TMP_EXTRA_CONFIGFILE >> "$conf"
fi
set +e
# Clean-up duplicate configs
if diff -q "${bak_env:-}" "$OVPN_ENV" 2>/dev/null; then
echo "Removing duplicate back-up: $bak_env"
rm -fv "$bak_env"
fi
if diff -q "${bak:-}" "$conf" 2>/dev/null; then
echo "Removing duplicate back-up: $bak"
rm -fv "$bak"
fi
echo "Successfully generated config"

132
docker/bin/ovpn_getclient Executable file
View File

@@ -0,0 +1,132 @@
#!/bin/bash
#
# Get an OpenVPN client configuration file
#
if [ "$DEBUG" == "1" ]; then
set -x
fi
set -e
if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD"
fi
if ! source "$OPENVPN/ovpn_env.sh"; then
echo "Could not source $OPENVPN/ovpn_env.sh."
exit 1
fi
if [ -z "$EASYRSA_PKI" ]; then
export EASYRSA_PKI="$OPENVPN/pki"
fi
cn="$1"
parm="$2"
if [ ! -f "$EASYRSA_PKI/private/${cn}.key" ]; then
echo "Unable to find \"${cn}\", please try again or generate the key first" >&2
exit 1
fi
get_client_config() {
mode="$1"
echo "
client
nobind
dev $OVPN_DEVICE
remote-cert-tls server
remote $OVPN_CN $OVPN_PORT $OVPN_PROTO"
if [ "$OVPN_PROTO" == "udp6" ]; then
echo "remote $OVPN_CN $OVPN_PORT udp"
fi
if [ "$OVPN_PROTO" == "tcp6" ]; then
echo "remote $OVPN_CN $OVPN_PORT tcp"
fi
for i in "${OVPN_EXTRA_CLIENT_CONFIG[@]}"; do
echo "$i"
done
if [ "$mode" == "combined" ]; then
echo "
<key>
$(cat $EASYRSA_PKI/private/${cn}.key)
</key>
<cert>
$(openssl x509 -in $EASYRSA_PKI/issued/${cn}.crt)
</cert>
<ca>
$(cat $EASYRSA_PKI/ca.crt)
</ca>
key-direction 1
<tls-auth>
$(cat $EASYRSA_PKI/ta.key)
</tls-auth>
"
elif [ "$mode" == "separated" ]; then
echo "
key ${cn}.key
ca ca.crt
cert ${cn}.crt
tls-auth ta.key 1
"
fi
if [ "$OVPN_DEFROUTE" != "0" ];then
echo "redirect-gateway def1"
fi
if [ -n "$OVPN_MTU" ]; then
echo "tun-mtu $OVPN_MTU"
fi
if [ -n "$OVPN_TLS_CIPHER" ]; then
echo "tls-cipher $OVPN_TLS_CIPHER"
fi
if [ -n "$OVPN_CIPHER" ]; then
echo "cipher $OVPN_CIPHER"
fi
if [ -n "$OVPN_AUTH" ]; then
echo "auth $OVPN_AUTH"
fi
if [ -n "$OVPN_OTP_AUTH" ]; then
echo "auth-user-pass"
echo "auth-nocache"
fi
if [ "$OVPN_COMP_LZO" == "1" ]; then
echo "comp-lzo"
fi
if [ -n "$OVPN_OTP_AUTH" ]; then
echo reneg-sec 0
fi
}
dir="$OPENVPN/clients/$cn"
case "$parm" in
"separated")
mkdir -p "$dir"
get_client_config "$parm" > "$dir/${cn}.ovpn"
cp "$EASYRSA_PKI/private/${cn}.key" "$dir/${cn}.key"
cp "$EASYRSA_PKI/ca.crt" "$dir/ca.crt"
cp "$EASYRSA_PKI/issued/${cn}.crt" "$dir/${cn}.crt"
cp "$EASYRSA_PKI/ta.key" "$dir/ta.key"
;;
"" | "combined")
get_client_config "combined"
;;
"combined-save")
mkdir -p "$dir"
get_client_config "combined" > "$dir/${cn}-combined.ovpn"
;;
*)
echo "This script can produce the client configuration in two formats:" >&2
echo " 1. combined (default): All needed configuration and cryptographic material is in one file (Use \"combined-save\" to write the configuration file in the same path as the separated parameter does)." >&2
echo " 2. separated: Separated files." >&2
echo "Please specify one of those options as second parameter." >&2
;;
esac

25
docker/bin/ovpn_getclient_all Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
## @licence MIT <http://opensource.org/licenses/MIT>
## @author Copyright (C) 2015 Robin Schneider <ypid@riseup.net>
if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD"
fi
if ! source "$OPENVPN/ovpn_env.sh"; then
echo "Could not source $OPENVPN/ovpn_env.sh."
exit 1
fi
if [ -z "$EASYRSA_PKI" ]; then
export EASYRSA_PKI="$OPENVPN/pki"
fi
pushd "$EASYRSA_PKI"
for name in issued/*.crt; do
name=${name%.crt}
name=${name#issued/}
if [ "$name" != "$OVPN_CN" ]; then
ovpn_getclient "$name" separated
ovpn_getclient "$name" combined-save
fi
done
popd

View File

@@ -4,7 +4,11 @@
# Initialize the EasyRSA PKI # Initialize the EasyRSA PKI
# #
set -ex if [ "$DEBUG" == "1" ]; then
set -x
fi
set -e
source "$OPENVPN/ovpn_env.sh" source "$OPENVPN/ovpn_env.sh"
@@ -20,7 +24,7 @@ easyrsa init-pki
easyrsa build-ca $nopass easyrsa build-ca $nopass
easyrsa gen-dh easyrsa gen-dh
openvpn --genkey --secret $OPENVPN/pki/ta.key openvpn --genkey --secret $EASYRSA_PKI/ta.key
# Was nice to autoset, but probably a bad idea in practice, users should # Was nice to autoset, but probably a bad idea in practice, users should
# have to explicitly specify the common name of their server # have to explicitly specify the common name of their server
@@ -34,3 +38,6 @@ openvpn --genkey --secret $OPENVPN/pki/ta.key
# For a server key with a password, manually init; this is autopilot # For a server key with a password, manually init; this is autopilot
easyrsa build-server-full "$OVPN_CN" nopass easyrsa build-server-full "$OVPN_CN" nopass
# Generate the CRL for client/server certificates revocation.
easyrsa gen-crl

54
docker/bin/ovpn_listclients Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD"
fi
if ! source "$OPENVPN/ovpn_env.sh"; then
echo "Could not source $OPENVPN/ovpn_env.sh."
exit 1
fi
if [ -z "$EASYRSA_PKI" ]; then
export EASYRSA_PKI="$OPENVPN/pki"
fi
cd "$EASYRSA_PKI"
if [ -e crl.pem ]; then
cat ca.crt crl.pem > cacheck.pem
else
cat ca.crt > cacheck.pem
fi
echo "name,begin,end,status"
for name in issued/*.crt; do
path=$name
begin=$(openssl x509 -noout -startdate -in $path | awk -F= '{ print $2 }')
end=$(openssl x509 -noout -enddate -in $path | awk -F= '{ print $2 }')
name=${name%.crt}
name=${name#issued/}
if [ "$name" != "$OVPN_CN" ]; then
# check for revocation or expiration
command="openssl verify -crl_check -CAfile cacheck.pem $path"
result=$($command)
if [ $(echo "$result" | wc -l) == 1 ] && [ "$(echo "$result" | grep ": OK")" ]; then
status="VALID"
else
result=$(echo "$result" | tail -n 1 | grep error | cut -d" " -f2)
case $result in
10)
status="EXPIRED"
;;
23)
status="REVOKED"
;;
*)
status="INVALID"
esac
fi
echo "$name,$begin,$end,$status"
fi
done
# Clean
rm cacheck.pem

33
docker/bin/ovpn_otp_user Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
#
# Generate OpenVPN users via google authenticator
#
if ! source "$OPENVPN/ovpn_env.sh"; then
echo "Could not source $OPENVPN/ovpn_env.sh."
exit 1
fi
if [ "x$OVPN_OTP_AUTH" != "x1" ]; then
echo "OTP authentication not enabled, please regenerate configuration using -2 flag"
exit 1
fi
if [ -z $1 ]; then
echo "Usage: ovpn_otp_user USERNAME"
exit 1
fi
# Ensure the otp folder is present
[ -d /etc/openvpn/otp ] || mkdir -p /etc/openvpn/otp
# Binary is present in image, save an $user.google_authenticator file in /etc/openvpn/otp
if [ "$2" == "interactive" ]; then
# Authenticator will ask for other parameters. User can choose rate limit, token reuse policy and time window policy
# Always use time base OTP otherwise storage for counters must be configured somewhere in volume
google-authenticator --time-based --force -l "${1}@${OVPN_CN}" -s /etc/openvpn/otp/${1}.google_authenticator
else
google-authenticator --time-based --disallow-reuse --force --rate-limit=3 --rate-time=30 --window-size=3 \
-l "${1}@${OVPN_CN}" -s /etc/openvpn/otp/${1}.google_authenticator
fi

61
docker/bin/ovpn_revokeclient Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
#
# Revoke a client certificate
#
if [ "$DEBUG" == "1" ]; then
set -x
fi
set -e
if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD"
fi
if ! source "$OPENVPN/ovpn_env.sh"; then
echo "Could not source $OPENVPN/ovpn_env.sh."
exit 1
fi
if [ -z "$EASYRSA_PKI" ]; then
export EASYRSA_PKI="$OPENVPN/pki"
fi
cn="$1"
parm="$2"
if [ ! -f "$EASYRSA_PKI/private/${cn}.key" ]; then
echo "Unable to find \"${cn}\", please try again or generate the key first" >&2
exit 1
fi
revoke_client_certificate(){
easyrsa revoke "$1"
echo "Generating the Certificate Revocation List :"
easyrsa gen-crl
cp -f "$EASYRSA_PKI/crl.pem" "$OPENVPN/crl.pem"
chmod 644 "$OPENVPN/crl.pem"
}
remove_files(){
rm -v "$EASYRSA_PKI/issued/${1}.crt"
rm -v "$EASYRSA_PKI/private/${1}.key"
rm -v "$EASYRSA_PKI/reqs/${1}.req"
}
case "$parm" in
"remove")
revoke_client_certificate "$cn"
remove_files "$cn"
;;
"" | "keep")
revoke_client_certificate "$cn"
;;
*)
echo "When revoking a client certificate, this script let you choose if you want to remove the corresponding crt, key and req files." >&2
echo "Pease note that the removal of those files is required if you want to generate a new client certificate using the revoked certificate's CN." >&2
echo " 1. keep (default): Keep the files." >&2
echo " 2. remove: Remove the files." >&2
echo "Please specify one of those options as second parameter." >&2
;;
esac

107
docker/bin/ovpn_run Executable file
View File

@@ -0,0 +1,107 @@
#!/bin/bash
#
# Run the OpenVPN server normally
#
if [ "$DEBUG" == "1" ]; then
set -x
fi
set -e
cd $OPENVPN
# Build runtime arguments array based on environment
USER_ARGS=("${@}")
ARGS=()
# Checks if ARGS already contains the given value
function hasArg {
local element
for element in "${@:2}"; do
[ "${element}" == "${1}" ] && return 0
done
return 1
}
# Adds the given argument if it's not already specified.
function addArg {
local arg="${1}"
[ $# -ge 1 ] && local val="${2}"
if ! hasArg "${arg}" "${USER_ARGS[@]}"; then
ARGS+=("${arg}")
[ $# -ge 1 ] && ARGS+=("${val}")
fi
}
# set up iptables rules and routing
# this allows rules/routing to be altered by supplying this function
# in an included file, such as ovpn_env.sh
function setupIptablesAndRouting {
iptables -t nat -C POSTROUTING -s $OVPN_SERVER -o $OVPN_NATDEVICE -j MASQUERADE || {
iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o $OVPN_NATDEVICE -j MASQUERADE
}
for i in "${OVPN_ROUTES[@]}"; do
iptables -t nat -C POSTROUTING -s "$i" -o $OVPN_NATDEVICE -j MASQUERADE || {
iptables -t nat -A POSTROUTING -s "$i" -o $OVPN_NATDEVICE -j MASQUERADE
}
done
}
addArg "--config" "$OPENVPN/openvpn.conf"
source "$OPENVPN/ovpn_env.sh"
mkdir -p /dev/net
if [ ! -c /dev/net/tun ]; then
mknod /dev/net/tun c 10 200
fi
if [ -d "$OPENVPN/ccd" ]; then
addArg "--client-config-dir" "$OPENVPN/ccd"
fi
# When using --net=host, use this to specify nat device.
[ -z "$OVPN_NATDEVICE" ] && OVPN_NATDEVICE=eth0
# Setup NAT forwarding if requested
if [ "$OVPN_DEFROUTE" != "0" ] || [ "$OVPN_NAT" == "1" ] ; then
# call function to setup iptables rules and routing
# this allows rules to be customized by supplying
# a replacement function in, for example, ovpn_env.sh
setupIptablesAndRouting
fi
# Use a copy of crl.pem as the CRL Needs to be readable by the user/group
# OpenVPN is running as. Only pass arguments to OpenVPN if it's found.
if [ "$EASYRSA_PKI/crl.pem" -nt "$OPENVPN/crl.pem" ]; then
cp -f "$EASYRSA_PKI/crl.pem" "$OPENVPN/crl.pem"
chmod 644 "$OPENVPN/crl.pem"
fi
if [ -r "$OPENVPN/crl.pem" ]; then
addArg "--crl-verify" "$OPENVPN/crl.pem"
fi
# If this fails, ensure the docker container is run with --privileged
# Could be side stepped with `ip netns` madness to drop privileged flag
echo "Enabling IPv4 Forwarding"
sysctl -w net.ipv4.ip_forward=1 || echo "Failed to enable IPv4 forwarding"
ip -6 route show default 2>/dev/null
if [ $? = 0 ]; then
echo "Enabling IPv6 Forwarding"
# If this fails, ensure the docker container is run with --privileged
# Could be side stepped with `ip netns` madness to drop privileged flag
sysctl -w net.ipv6.conf.all.disable_ipv6=0 || echo "Failed to enable IPv6 support"
sysctl -w net.ipv6.conf.default.forwarding=1 || echo "Failed to enable IPv6 Forwarding default"
sysctl -w net.ipv6.conf.all.forwarding=1 || echo "Failed to enable IPv6 Forwarding"
fi
echo "Running 'openvpn ${ARGS[@]} ${USER_ARGS[@]}'"
exec openvpn ${ARGS[@]} ${USER_ARGS[@]}

View File

@@ -3,7 +3,10 @@
# #
# Get OpenVPN server status # Get OpenVPN server status
# #
if [ "$DEBUG" == "1" ]; then
set -x
fi
set -ex set -e
tail -F /tmp/openvpn-status.log tail -F /tmp/openvpn-status.log

7
docker/otp/openvpn Normal file
View File

@@ -0,0 +1,7 @@
# Uses google authenticator library as PAM module using a single folder for all users tokens
# User root is required to stick with an hardcoded user when trying to determine user id and allow unexisting system users
# See https://github.com/google/google-authenticator-libpam#usersome-user
auth required pam_google_authenticator.so secret=/etc/openvpn/otp/${USER}.google_authenticator user=root
# Accept any user since we're dealing with virtual users there's no need to have a system account (pam_unix.so)
account sufficient pam_permit.so

View File

@@ -1,18 +0,0 @@
# Backing Up Configuration and Certificates
## Security
The resulting archive from this back-up contains all credential to impersonate the server at a minimum. If the client private keys are generated using the EasyRSA utility then it also contains the client certificates that could be used to impersonate said clients. Most importantly, if the certificate authority key is in this archive (as it is given the quick start directions), then a adversary could generate certificates at will.
I'd recommend encrypting the archive with something strong (e.g. gpg or openssl + AES). For the paranoid keep backup offline. For the truly paranoid users, never keep any keys (i.e. client and certificate authority) in the docker container to begin with :).
TL;DR Protect the resulting archive file, by ensure there is very limited access to it.
## Backup to Archive
docker run --volumes-from openvpn-data --rm busybox tar -cvf - -C /etc openvpn | xz > openvpn-backup.tar.xz
## Retore to New Image
xzcat openvpn-backup.tar.xz | docker run --name openvpn-data -v /etc/openvpn -i busybox tar -xvf - -C /etc

View File

@@ -1,32 +0,0 @@
# Debugging
Random things I do to debug the containers.
## Stream OpenVPN Logs
1. Get the container's name or container ID:
root@vpn:~/docker-openvpn# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ed335aaa9b82 kylemanna/openvpn:latest ovpn_run 5 minutes ago Up 5 minutes 0.0.0.0:1194->1194/udp sad_lovelace
2. Tail the logs:
root@vpn:~/docker-openvpn# docker logs -f sad_lovelace
+ mkdir -p /dev/net
+ [ ! -c /dev/net/tun ]
+ mknod /dev/net/tun c 10 200
+ [ ! -d /etc/openvpn/ccd ]
+ iptables -t nat -A POSTROUTING -s 192.168.254.0/24 -o eth0 -j MASQUERADE
+ iptables -t nat -A POSTROUTING -s 192.168.255.0/24 -o eth0 -j MASQUERADE
+ conf=/etc/openvpn/openvpn.conf
+ [ ! -s /etc/openvpn/openvpn.conf ]
+ conf=/etc/openvpn/udp1194.conf
+ openvpn --config /etc/openvpn/udp1194.conf
Tue Jul 1 06:56:48 2014 OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Mar 17 2014
Tue Jul 1 06:56:49 2014 Diffie-Hellman initialized with 2048 bit key
Tue Jul 1 06:56:49 2014 Control Channel Authentication: using '/etc/openvpn/pki/ta.key' as a OpenVPN static key file
Tue Jul 1 06:56:49 2014 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Tue Jul 1 06:56:49 2014 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Tue Jul 1 06:56:49 2014 Socket Buffers: R=[212992->131072] S=[212992->131072]

View File

@@ -1,24 +0,0 @@
# Static IP Addresses
The docker image is setup for static client configuration on the 192.168.254.0/24 subnet. To use it follow the Quick Start section below. Note that the IP addresses octects need to be picked special, see [OpenVPN Documentation](https://openvpn.net/index.php/open-source/documentation/howto.html#policy) for more details.
## Quick Start
1. Create a client specific configuration:
$ echo "ifconfig-push 192.168.254.1 192.168.254.2" | docker run --volumes-from openvpn-data -i --rm kylemanna/openvpn tee /etc/openvpn/ccd/CERT_COMMON_NAME
ifconfig-push 192.168.254.1 192.168.254.2
2. Wait for client to reconnect if necessary
## Advanced Admin
Login to the openvpn-data volume with a `bash` container, note only changes in /etc/openvpn will persist:
docker run --volumes-from openvpn-data -it --rm kylemanna/openvpn bash -l
## Upgrading from Old OpenVPN Configurations
If you're running an old configuration and need to upgrade it to pull in the ccd directory run the following:
docker run --volumes-from openvpn-data --rm kylemanna/openvpn ovpn_genconfig