OpenVPN - Setup Windows Client

 

 

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DATE=`date +%d-%m-%Y\ %H:%M`
MSDATE=`date +%Y-%m-%d\ %H:%M:00`


if [ -n "$1" ]
then
export CLIENT="$1"
if [ ! -f /etc/openvpn/${CLIENT}.crt ]
then
echo "You specified a non existing client name : $1"
echo "Exit..."
exit
fi
else
export CLIENT=Ad
fi

cd /root/
mkdir openvpn-profiles 2>/dev/null
WORKDIR=/root/openvpn-profiles
cd ${WORKDIR}

#
# Start from here with generating the needed profiles...
#

# 2nd Profile used by Windows PC/Laptop
#
# Windows Client
#
if [ -f /etc/openvpn/${CLIENT}-WIN.crt ]
then

export OVPN=${WORKDIR}/${CLIENT}-WIN.ovpn

> ${OVPN}
echo "client" >> ${OVPN}
echo "dev tun" >> ${OVPN}
echo "proto tcp" >> ${OVPN}
echo "remote <Your Domain/Servername> <Your configured portnumber>" >> ${OVPN}
echo "resolv-retry infinite" >> ${OVPN}
echo "nobind" >> ${OVPN}
echo "remote-cert-tls server" >> ${OVPN}
echo "cipher AES-256-CBC" >> ${OVPN}
echo "auth SHA512" >> ${OVPN}
echo "auth-nocache" >> ${OVPN}
echo "tls-version-min 1.2" >> ${OVPN}
echo "tls-cipher TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-256-CBC-SHA256:TLS-DHE-RSA-WITH-AES-128-GCM-SHA256:TLS-DHE-RSA-WITH-AES-128-CBC-SHA256" >> ${OVPN}
echo "persist-key" >> ${OVPN}
echo "persist-tun" >> ${OVPN}
echo "mute-replay-warnings" >> ${OVPN}
echo "verb 0" >> ${OVPN}
echo "set CLIENT_CERT 0" >> ${OVPN}

echo "<ca>" >> ${OVPN}
cat /etc/openvpn/ca.crt | grep -A 100 "BEGIN CERTIFICATE" | grep -B 100 "END CERTIFICATE" >> ${OVPN}
echo "</ca>" >> ${OVPN}

echo "<cert>" >> ${OVPN}
cat /etc/openvpn/${CLIENT}-WIN.crt | grep -A 100 "BEGIN CERTIFICATE" | grep -B 100 "END CERTIFICATE" >> ${OVPN}
echo "</cert>" >> ${OVPN}

echo "<key>" >> ${OVPN}
cat /etc/openvpn/${CLIENT}-WIN.key | grep -A 100 "BEGIN ENCRYPTED PRIVATE KEY" | grep -B 100 "END ENCRYPTED PRIVATE KEY" >> ${OVPN}
echo "</key>" >> ${OVPN}

 

echo "OpenVPN Windows ${CLIENT}" | mail -A ${OVPN} -s "OpenVPN Windows ${CLIENT} : Save this ovpn-file to for example Onedrive and open it on Windows with OpenVPN" <E-mail address of Client user>

 

  Donate now via the Paypal button on the top in US Dollar and on the bottom in Euro