Skip to content

Instantly share code, notes, and snippets.

@chreniuc
Created June 4, 2019 17:41
Show Gist options
  • Save chreniuc/0bbab8fc4fe0e1b65bddd16fcd0e58c0 to your computer and use it in GitHub Desktop.
Save chreniuc/0bbab8fc4fe0e1b65bddd16fcd0e58c0 to your computer and use it in GitHub Desktop.
Start vpn conainer
# Script to start a openvpn server
IP="1.1.1.1" # Public ip
PORT="7777" # External port
USER="chreniuc" # User for vpn
OPEN_VPN_MOUNT="$(pwd)/home_test/" # Where open vpn should store all its data. This should exist.
echo "Generating config..."
docker run -v ${OPEN_VPN_MOUNT}:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://${IP}:${PORT}
echo "Initialising certificates..."
docker run -v ${OPEN_VPN_MOUNT}:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
echo "Starting daemon..."
docker run -v ${OPEN_VPN_MOUNT}:/etc/openvpn --restart=always -d -p ${PORT}:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
echo "Adding client..."
docker run -v ${OPEN_VPN_MOUNT}:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full ${USER} nopass
echo "Getting client info..."
docker run -v ${OPEN_VPN_MOUNT}:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient ${USER} > ${USER}.ovpn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment