-
-
Save beebird/45f59b0f6f40b48449876cba848232d7 to your computer and use it in GitHub Desktop.
Script for OpenVPN generate client config file.
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
#!/bin/bash | |
# Easy script to create OpenVPN client configuration with the user, pre-generating user's | |
# RSA key and certificate. | |
# | |
# Configuration template must exist in the same directory, with only missing part: certificates. | |
# | |
# (c) Dmytro Kovalov, 2015 | |
# | |
cd $(dirname ${BASH_SOURCE[0]}) | |
read -p "Please type in user name for the new config: " USER | |
[ -z ${USER} ] && { echo "Cannot be empty"; exit 1; } | |
[ -f keys/${USER}.crt ] && { echo "Certificate keys/${USER}.crt already exists"; exit 2; } | |
source ./vars | |
./build-key ${USER} | |
( | |
# This should be existing config template, with only missing certificates, and keys sections. | |
cat config.ovpn.tpl | |
echo '<key>' | |
cat keys/${USER}.key | |
echo '</key>' | |
echo '<cert>' | |
cat keys/${USER}.crt | |
echo '</cert>' | |
echo '<ca>' | |
cat keys/ca.crt | |
echo '</ca>' | |
) > openvpn_${USER}.ovpn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment