Last active
March 7, 2016 11:51
-
-
Save tunght13488/767d70bf79aa317279b6 to your computer and use it in GitHub Desktop.
Generate unified OpenVPN client profile
This file contains hidden or 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
#!/bin/sh | |
# Follow https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04 | |
# Use to quickly generate a client.ovpn file and copy it to destination folder | |
# Sample: sudo ./generate-ovpn.sh digital-ocean /home/myusername/openvpn | |
CLIENT="$1" | |
DEST="$2" | |
OPENVPN_HOME=/etc/openvpn | |
OPENVPN_KEYS=${OPENVPN_HOME}/easy-rsa/keys | |
CA_FILE=${OPENVPN_HOME}/ca.crt | |
CERT_FILE=${OPENVPN_KEYS}/${CLIENT}.crt | |
KEY_FILE=${OPENVPN_KEYS}/${CLIENT}.key | |
BASE_OVPN_FILE=${OPENVPN_KEYS}/client.ovpn | |
OPVN_FILE=${OPENVPN_KEYS}/${CLIENT}.ovpn | |
echo "Building unified OpenVPN client profile '${CLIENT}' to ${DEST}/${CLIENT}.ovpn" | |
${OPENVPN_HOME}/easy-rsa/build-key ${CLIENT} | |
cp ${BASE_OVPN_FILE} ${OPVN_FILE} | |
echo "<ca>" >> ${OPVN_FILE} | |
cat ${CA_FILE} >> ${OPVN_FILE} | |
echo "</ca>" >> ${OPVN_FILE} | |
echo "<cert>" >> ${OPVN_FILE} | |
cat ${CERT_FILE} >> ${OPVN_FILE} | |
echo "</cert>" >> ${OPVN_FILE} | |
echo "<key>" >> ${OPVN_FILE} | |
cat ${KEY_FILE} >> ${OPVN_FILE} | |
echo "</key>" >> ${OPVN_FILE} | |
cp ${OPVN_FILE} ${DEST}/${CLIENT}.ovpn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment