Isso foi testado com o OpenVPN 2.3.4 Debian 8.9 Server com clientes Win7.
Etapa 1. Crie um arquivo contendo seus padrões (eu chamo de inline_client.conf). Todas as configurações devem corresponder aos seus valores server.conf
client
dev tun
proto udp
remote yourserver.xyz 1194
resolv-retry infinite
nobind
persist-key
persist-tun
mute-replay-warnings
remote-cert-tls server
cipher AES-256-CBC
comp-lzo
verb 3
;mute 20
ca [inline]
cert [inline]
key [inline]
tls-auth [inline] 1
Etapa 2. Crie o script a seguir, ajuste os caminhos conforme necessário e
chmod ug+x MakeInline.sh
#!/bin/bash
# Default Variable Declarations
DEFAULT="inline_client.conf"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".key"
CA="ca.crt"
TA="ta.key"
kPath="./keys/"
#Ask for a Client name
echo "Please enter an existing Client Name:"
read NAME
echo "Please enter an Name for the output file"
read ovpnName
#1st Verify that client's Public Key Exists
if [ ! -f $kPath$NAME$CRT ]; then
echo "[ERROR]: Client Public Key Certificate not found: $kPath$NAME$CRT"
exit
fi
echo "Client's cert found: $kPath$NAME$CRT"
#Then, verify that there is a private key for that client
if [ ! -f $kPath$NAME$KEY ]; then
echo "[ERROR]: Client 3des Private Key not found: $kPath$NAME$KEY"
exit
fi
echo "Client's Private Key found: $kPath$NAME$KEY"
#Confirm the CA public key exists
if [ ! -f $kPath$CA ]; then
echo "[ERROR]: CA Public Key not found: $kPath$CA"
exit
fi
echo "CA public Key found: $kPath$CA"
#Confirm the tls-auth ta key file exists
if [ ! -f $kPath$TA ]; then
echo "[ERROR]: tls-auth Key not found: $kPath$TA"
exit
fi
echo "tls-auth Private Key found: $kPath$TA"
#Ready to make a new .opvn file - Start by populating with the
cat $DEFAULT > $ovpnName$FILEEXT
#Now, append the CA Public Cert
echo "<ca>" >> $ovpnName$FILEEXT
cat $kPath$CA | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> $ovpnName$FILEEXT
echo "</ca>" >> $ovpnName$FILEEXT
#Next append the client Public Cert
echo "<cert>" >> $ovpnName$FILEEXT
cat $kPath$NAME$CRT | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> $ovpnName$FILEEXT
echo "</cert>" >> $ovpnName$FILEEXT
#Then, append the client Private Key
echo "<key>" >> $ovpnName$FILEEXT
cat $kPath$NAME$KEY >> $ovpnName$FILEEXT
echo "</key>" >> $ovpnName$FILEEXT
#Finally, append the TA Private Key
echo "<tls-auth>" >> $ovpnName$FILEEXT
cat $kPath$TA >> $ovpnName$FILEEXT
echo "</tls-auth>" >> $ovpnName$FILEEXT
echo "Done! $ovpnName$FILEEXT Successfully Created."
#Script written by Eric Jodoin
#Update by Eric Maasdorp 2017-12-16
Etapa 3. Execute, MakeInline.sh
ele solicitará o nome de um cliente com o qual você precisa já ter criado build-key or build-key-pass
. Ele solicitará um nome para o arquivo ovpn. Meu padrão é ServerToConnectTo.ClientName, que produzirá
ServerToConnectTo.ClientName.ovpn
Nota: se você usou em build-key
vez de build-key-pass
, qualquer pessoa que se apossar dele *.ovpn
terá acesso ao seu servidor sem uma senha!
Could not read file C:\\...\[inline]
pelo que parece que o cliente ainda não sabe sobre certificados embutidos.