-
-
Save vadikgo/276c4b0c5475ada0c52b7d3f393b1406 to your computer and use it in GitHub Desktop.
Run OpenVPN Server in Docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# https://hub.docker.com/r/kylemanna/openvpn/ | |
OVPN_DATA="openvpn_data" # Docker volume name | |
OVPN_HOST="vpn.hostname.org" # Server hostname | |
OVPN_USER="peter_the_pig" # Client username | |
# init | |
docker volume create --name $OVPN_DATA | |
docker run -v $OVPN_DATA:/etc/openvpn \ | |
--rm kylemanna/openvpn ovpn_genconfig \ | |
-u udp://$OVPN_HOST | |
docker run -v $OVPN_DATA:/etc/openvpn \ | |
--rm -it kylemanna/openvpn ovpn_initpki | |
# start | |
docker run -v $OVPN_DATA:/etc/openvpn \ | |
-d -p 1194:1194/udp --cap-add=NET_ADMIN \ | |
--restart unless-stopped --name=openvpn \ | |
kylemanna/openvpn | |
# Generate a client certificate without a passphrase | |
docker run -v $OVPN_DATA:/etc/openvpn \ | |
--rm -it kylemanna/openvpn easyrsa build-client-full \ | |
$OVPN_USER@$OVPN_HOST nopass | |
# Retrieve the client configuration with embedded certificates | |
docker run -v $OVPN_DATA:/etc/openvpn \ | |
--rm kylemanna/openvpn ovpn_getclient \ | |
$OVPN_USER@$OVPN_HOST > $OVPN_USER@$OVPN_HOST.ovpn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment