Skip to content

Instantly share code, notes, and snippets.

@codeopensrc
Last active February 13, 2016 08:18
Show Gist options
  • Save codeopensrc/719a50065d9b16726d8a to your computer and use it in GitHub Desktop.
Save codeopensrc/719a50065d9b16726d8a to your computer and use it in GitHub Desktop.
Quickly create multiple client .ovpn's from a template .ovpn
#!/bin/bash
# First of course, build your key(s) using `./build-key my-new-client` in the /etc/openvpn/easy-rsa dir
# Within the /etc/openvpn/easy-rsa/keys directory
# (or wherever you have your built-keys at)
# bash createClientOvpn.sh my-template-ovpn my-new-client Think cp command
# or ./createClientOvpn.sh my-template-ovpn my-new-client2
cp $1.ovpn $2.ovpn;
echo "<ca>" >> $2.ovpn;
cat ca.crt >> $2.ovpn;
echo -e "</ca>\n<cert>" >> $2.ovpn;
cat $2.crt >> $2.ovpn;
echo -e "</cert>\n<key>" >> $2.ovpn;
cat $2.key >> $2.ovpn;
echo "</key>" >> $2.ovpn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment