Deve ser guardado em /etc/openvpn/easy-rsa/keys/mergeKeys.sh
E deve ser invocado a partir dessa localização com o argumento do nome do cliente. Por exemplo:
./mergeKeys.sh tabuleta
Para criar tabuleta.ovpn, a partir de ca.crt, tabuleta.crt e tabuleta.key.
Deve copiar-se o perfil de exemplo OVPN para template.ovpn e configurá-lo de acordo com o servidor.
mergeKeys.sh
#!/bin/bash# Check for client name
echo -e "Checking for client name... "
if [ $# -eq 0 ]; then
echo -e "ERROR: No client name provided.\nAborting."
echo -e "\nYou have to supply the client name for the certificate. eg:\n$0 client1\n"
exit 1
else
echo -e "Using $1 to find certificates..."
fi
# Check for client.ovpn
if [ -f "$1.ovpn" ]; then
echo -e "WARNING: $1.ovpn already exist."
echo -e "\nAborting."
exit 1
fi
FILE=template.ovpn
echo -e "Checking for template profile $FILE... "
if [ ! -f $FILE ]; then
echo -e "ERROR: $FILE not found."
echo -e "\nAborting."
exit 1
fi
FILE=ca.crt
echo -e "Checking for $FILE... "
if [ ! -f $FILE ]; then
echo -e "ERROR: $FILE not found."
echo -e "\nAborting."
exit 1
fi
FILE="$1.crt"
echo -e "Checking for $FILE... "
if [ ! -f $FILE ]; then
echo -e "ERROR: $FILE not found."
echo -e "\nAborting."
exit 1
fi
FILE="$1.key"
echo -e "Checking for $FILE... "
if [ ! -f $FILE ]; then
echo -e "ERROR: $FILE not found."
echo -e "\nAborting."
exit 1
fi
# All files exist
echo -e "All files exist.\n"
FILE=client.ovpn
echo "Creating $1.ovpn base file with $FILE..."
cp "$FILE" "$1.ovpn"
if [ ! -f "$1.ovpn" ]; then
echo -e "ERROR: $1.ovpn couldn't be created. Check permissions."
echo -e "\nAborting."
exit 1
fi
FILE=ca.crt
echo "Append $FILE to $1.ovpn..."
echo "<ca>" >> "$1.ovpn"
cat "$FILE" >> "$1.ovpn"
echo "</ca>" >> "$1.ovpn"
FILE="$1.crt"
echo "Append $FILE to $1.ovpn..."
echo "<cert>" >> "$1.ovpn"
cat "$FILE" >> "$1.ovpn"
echo "</cert>" >> "$1.ovpn"
FILE="$1.key"
echo "Append $FILE to $1.ovpn..."
echo "<key>" >> "$1.ovpn"
cat "$FILE" >> "$1.ovpn"
echo "</key>" >> "$1.ovpn"
echo -e "Done.\n"
Sem comentários:
Enviar um comentário