Skip to content

Instantly share code, notes, and snippets.

@sunapi386
Created February 10, 2018 15:45
Show Gist options
  • Select an option

  • Save sunapi386/7f0f9ea577ba66658313b0b7da02a45c to your computer and use it in GitHub Desktop.

Select an option

Save sunapi386/7f0f9ea577ba66658313b0b7da02a45c to your computer and use it in GitHub Desktop.
OpenVPN
#!/bin/bash
echo "$# arguments"
if [ $# -ne 1 ]; then
echo "illegal number of parameters"
exit -1
fi
# Generate a client certificate
export CLIENTNAME="$1"
echo $CLIENTNAME
# with a passphrase (recommended)
docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME
# without a passphrase (not recommended)
# docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME nopass
# Retrieve the client configuration with embedded certificates
docker-compose run --rm openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn
echo "Complete"
#!/bin/bash
export SERVERNAME="tokyo.sunpi.co"
export CLIENTNAME="tokyo"
docker-compose run --rm openvpn ovpn_genconfig -u udp://$SERVERNAME
docker-compose run --rm openvpn ovpn_initpki
# Fix ownership (depending on how to handle your backups, this may not be needed)
sudo chown -R $(whoami): ./openvpn-data
# Start OpenVPN server process
docker-compose up -d openvpn
# You can access the container logs with
docker-compose logs -f
# Generate a client certificate
# with a passphrase (recommended)
docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME
# without a passphrase (not recommended)
# docker-compose run --rm openvpn easyrsa build-client-full $CLIENTNAME nopass
# Retrieve the client configuration with embedded certificates
docker-compose run --rm openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment