===== OpenVPN ===== Mit OpenVPN von Überall ins eigene/heimische Netz. Hier a Beispiel mit FLi4L als Router. ==== Quellen: ==== * [[https://linuxconfig.org/how-to-setup-a-openvpn-server-on-ubuntu-20-04|https://linuxconfig.org/how-to-setup-a-openvpn-server-on-ubuntu-20-04]] - OpenVPN Server unter Ubuntu 20.04 aufsetzten * [[https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-18-04-de|https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-18-04-de]] - OpenVPN Server unter Ubuntu 18.04 aufsetzten * [[https://ubuntu.com/server/docs/service-openvpn|https://ubuntu.com/server/docs/service-openvpn]] * [[https://lists.spline.inf.fu-berlin.de/pipermail/fli4l/2017-April/006451.html|https://lists.spline.inf.fu-berlin.de/pipermail/fli4l/2017-April/006451.html]] ==== Server ==== Zertifikate und Schlüssel für den Server erzeugen:\\ Vorbereitung: sudo apt-get install easy-rsa Arbeitsverzeichnis für die Erstellung der Schlüssel und Zertifikate erstellen: make-cadir My_Certificate_Authority && cd My_Certificate_Authority Parameter des Zertifikatsausstellers bearbeiten: mcedit vars ... set_var EASYRSA_REQ_COUNTRY "DE" set_var EASYRSA_REQ_PROVINCE "NIEDERSACHSEN" set_var EASYRSA_REQ_CITY "Hildesheim" set_var EASYRSA_REQ_ORG "Familie von Thuelen" set_var EASYRSA_REQ_EMAIL "Christoph@von-Thuelen.de" set_var EASYRSA_REQ_OU "Familie" ... #EOF [[https://de.wikipedia.org/wiki/Public-Key-Infrastruktur|PKI]] Initialisieren (Unterverzeichnisse werden erstellt): ./easyrsa init-pki ".rnd"-File generieren: openssl rand -writerand ./pki/.rnd [[https://de.wikipedia.org/wiki/Zertifizierungsstelle|CA]] Zertifikat erstellen: ./easyrsa build-ca nopass # ohne "nopass" --> Password: ZFxhJYWCGj2QUhMQ # mit "nopass" --> keine weitere Passwortabfrage # ... Common Name (eg: your user, host, or server name) [Easy-RSA CA]: # --> pki/private/ca.key # --> pki/ca.crt wird generiert Server Schlüssel erstellen: ./easyrsa gen-req dsl-router nopass # --> pki/reqs/dsl-router.req # --> pki/private/dsl-router.key Server Zertifikat erstellen: ./easyrsa sign-req server dsl-router # --> pki/issued/dsl-router.crt Diffie-Hellman Parameter erstellen: ./easyrsa gen-dh # --> pki/dh.pem cp pki/dh.pem /pki/dh2048.pem TSL-Auth Schlüssel erstellen: openvpn --genkey --secret tsl-auth.key # --> tsl-auth.key ==== Client ==== Zertifikate und Schlüssel für den Client erzeugen: make-cadir OpenVPN_Clients && cd OpenVPN_Clients Client Schlüssel erstellen: ./easyrsa gen-req Christophs_Smartphone nopass # --> pki/reqs/Christophs_Smartphone.req # --> pki/private/Christophs_Smartphone.key Client Zertifikat erstellen: ./easyrsa sign-req client Christophs_Smartphone # --> pki/issued/Christophs_Smartphone.crt OpenVPN Client Konfigurationsdatei "*.ovpn" erstellen: mkdir ../Christophs_Smartphone cp pki/ca.crt ../Christophs_Smartphone/ cp pki/issued/Christophs_Smartphone.crt ../Christophs_Smartphone/ cp pki/private/Christophs_Smartphone.key ../Christophs_Smartphone/ cp ../template_client_config.ovpn ../Christophs_Smartphone/Christophs_Smartphone.ovpn cp tsl-auth.key ../Christophs_Smartphone/ cd .. ./make_openvpn_client_config.sh Christophs_Smartphone client dev tun proto udp remote resolv-retry infinite nobind persist-key persist-tun key-direction 1 remote-cert-tls server cipher AES-256-CBC data-ciphers AES-256-CBC verb 3 #!/bin/bash # First argument: Client identifier CONFIG_NAME=$1 BASE_CONFIG=template_client_config.ovpn OUTPUT=$CONFIG_NAME.ovpn if [ -z "$CONFIG_NAME" ]; then echo "\$CONFIG_NAME is empty" echo "Please specify client config name. --> exit!" exit 1 else echo "Make OpenVPN client config for: $CONFIG_NAME" fi if [ -d $CONFIG_NAME ]; then echo "Generating $OUTPUT" cat ${BASE_CONFIG} \ <(echo -e '') \ $CONFIG_NAME/ca.crt \ <(echo -e '\n') \ $CONFIG_NAME/$CONFIG_NAME.crt \ <(echo -e '\n') \ $CONFIG_NAME/$CONFIG_NAME.key \ <(echo -e '\n') \ $CONFIG_NAME/tls-auth.key \ <(echo -e '') \ > $CONFIG_NAME/$CONFIG_NAME.ovpn else echo "ERROR: Folder for $CONFIG_NAME not found --> exit!" fi