Created
January 27, 2021 10:31
-
-
Save mcprat/83d891e5ced7f95db91a46e82be00d6a to your computer and use it in GitHub Desktop.
Universal Openvpn client OVPN generation script (tls-auth)
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 | |
PKI_DIR=/etc/openvpn/easy-rsa/pki | |
CRT_DIR=/etc/openvpn/easy-rsa/pki/issued | |
KEY_DIR=/etc/openvpn/easy-rsa/pki/private | |
OUTPUT_DIR=/etc/openvpn/server/clients | |
BASE_CONFIG=/etc/openvpn/server/client.confbase | |
cat ${BASE_CONFIG} > ${OUTPUT_DIR}/${1}.ovpn | |
echo '<ca>' | cat >> ${OUTPUT_DIR}/${1}.ovpn | |
cat ${PKI_DIR}/ca.crt >> ${OUTPUT_DIR}/${1}.ovpn | |
echo '</ca>\n<cert>' | cat >> ${OUTPUT_DIR}/${1}.ovpn | |
cat ${CRT_DIR}/${1}.crt >> ${OUTPUT_DIR}/${1}.ovpn | |
echo '</cert>\n<key>' | cat >> ${OUTPUT_DIR}/${1}.ovpn | |
cat ${KEY_DIR}/${1}.key >> ${OUTPUT_DIR}/${1}.ovpn | |
echo '</key>\n<tls-auth>' | cat >> ${OUTPUT_DIR}/${1}.ovpn | |
cat ${PKI_DIR}/../hmac.key >> ${OUTPUT_DIR}/${1}.ovpn | |
echo '</tls-auth>' | cat >> ${OUTPUT_DIR}/${1}.ovpn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment