Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| openvpn [2023/03/08 12:27] – [Ajout d'une interface de gestion] nekan | openvpn [2023/08/10 17:17] (Version actuelle) – [Ajout de la double authentification Google] nekan | ||
|---|---|---|---|
| Ligne 44: | Ligne 44: | ||
| <sxh bash> | <sxh bash> | ||
| - | * On met en place un raccourci vers les certificats dans le dossier de '' | + | * On met en place un raccourci vers les certificats dans le dossier de '' |
| - | <sxh bash>ln -sf / | + | <sxh bash>ln -sf / |
| + | ln -sf / | ||
| ==== Configuration du serveur ==== | ==== Configuration du serveur ==== | ||
| Ligne 85: | Ligne 86: | ||
| * **reneg-sec 86400** : limite la renégociation avec les clients à 1/jour (86400s). | * **reneg-sec 86400** : limite la renégociation avec les clients à 1/jour (86400s). | ||
| - | * On oublie pas de créer le dossier des configurations clientes : | + | * On n'oublie pas de créer le dossier des configurations clientes : |
| <sxh bash> | <sxh bash> | ||
| Ligne 136: | Ligne 137: | ||
| COMMIT | COMMIT | ||
| - | # | + | #==========================================# |
| - | # Partie clients # | + | # Partie clients |
| - | # | + | #==========================================# |
| *filter | *filter | ||
| - | # Autorisation à créer selon chaque | + | # Autorisation à créer selon chaque |
| - | # -I FORWARD -i tun0 -o ens192 -s 172.16.0.49 -d 10.1.1.1 | + | # -I FORWARD -i tun0 -o ens192 -s 172.16.0.0/24 -d 10.1.1.1 -j ACCEPT -m comment |
| - | # -I FORWARD | + | # -I FORWARD -i ens192 -o tun0 -s 10.1.1.1 -d 172.16.0.0/24 -j ACCEPT |
| - | # -I FORWARD -i ens192 -o tun0 -s 10.1.1.1 -d 172.16.0.49 -j ACCEPT | + | |
| # | # | ||
| Ligne 202: | Ligne 202: | ||
| comp-lzo | comp-lzo | ||
| verb 4 | verb 4 | ||
| + | # uncomment below lines for use with Google 2FA | ||
| + | # | ||
| cipher AES-256-GCM | cipher AES-256-GCM | ||
| key-direction 1 | key-direction 1 | ||
| Ligne 207: | Ligne 209: | ||
| remote-cert-tls server | remote-cert-tls server | ||
| auth-nocache | auth-nocache | ||
| - | + | explicit-exit-notify 1 | |
| - | + | reneg-sec 86400 | |
| # uncomment below lines for use with linux | # uncomment below lines for use with linux | ||
| # | # | ||
| Ligne 217: | Ligne 220: | ||
| #up / | #up / | ||
| #down / | #down / | ||
| - | + | ||
| - | {{- if .PasswdAuth }} | + | |
| - | auth-user-pass | + | |
| - | {{- end }} | + | |
| - | + | ||
| < | < | ||
| {{ .Cert -}} | {{ .Cert -}} | ||
| Ligne 240: | Ligne 239: | ||
| # Variables | # Variables | ||
| - | #OVPN_LISTEN_HOST=127.0.0.1 | + | OVPN_LISTEN_HOST=127.0.0.1 |
| - | OVPN_LISTEN_PORT=8080 # Port de l' | + | OVPN_LISTEN_PORT=8088 # Port de l' |
| OVPN_NETWORK=172.16.0.0/ | OVPN_NETWORK=172.16.0.0/ | ||
| OVPN_SERVER=1.2.3.4: | OVPN_SERVER=1.2.3.4: | ||
| Ligne 248: | Ligne 247: | ||
| EASYRSA_PATH="/ | EASYRSA_PATH="/ | ||
| OVPN_INDEX_PATH="/ | OVPN_INDEX_PATH="/ | ||
| - | # | ||
| OVPN_CCD_PATH="/ | OVPN_CCD_PATH="/ | ||
| OVPN_TEMPLATES_CC_PATH="/ | OVPN_TEMPLATES_CC_PATH="/ | ||
| Ligne 256: | Ligne 254: | ||
| / | / | ||
| + | --listen.host=$OVPN_LISTEN_HOST \ | ||
| + | --listen.port=$OVPN_LISTEN_PORT \ | ||
| --log.level=$LOG_LEVEL \ | --log.level=$LOG_LEVEL \ | ||
| --easyrsa.path=$EASYRSA_PATH \ | --easyrsa.path=$EASYRSA_PATH \ | ||
| Ligne 385: | Ligne 385: | ||
| CustomLog ${APACHE_LOG_DIR}/ | CustomLog ${APACHE_LOG_DIR}/ | ||
| - | ProxyPass | + | ProxyPass |
| - | ProxyPassReverse | + | ProxyPassReverse |
| ProxyRequests | ProxyRequests | ||
| < | < | ||
| Ligne 401: | Ligne 401: | ||
| * On crée le mot de passe : | * On crée le mot de passe : | ||
| < | < | ||
| - | * On active les modules '' | + | * On active les modules '' |
| <sxh bash> | <sxh bash> | ||
| + | a2enmod proxy | ||
| a2enmod proxy_http</ | a2enmod proxy_http</ | ||
| * On active le site : | * On active le site : | ||
| Ligne 415: | Ligne 416: | ||
| ===== Ajout de la double authentification Google ===== | ===== Ajout de la double authentification Google ===== | ||
| + | Pour activer le 2FA de Google, il faut au préalable ajouter le plugin dans la configuration serveur (voir plus haut). Ensuite : | ||
| + | * On installe les paquets nécessaires : | ||
| + | <sxh bash>apt install -y libqrencode4 libpam-google-authenticator</ | ||
| + | * On crée le script de création de 2FA ''/ | ||
| + | <sxh bash># | ||
| + | |||
| + | # Variables | ||
| + | SCRIPT_PATH="/ | ||
| + | CCD=" | ||
| + | |||
| + | # Usage | ||
| + | get-help() { | ||
| + | echo "Usage : ./ | ||
| + | echo " | ||
| + | exit 1 | ||
| + | } | ||
| + | |||
| + | # Test présence utilisateur | ||
| + | if [ -z " | ||
| + | get-help | ||
| + | elif [ ! -f $CCD/$1 ]; then | ||
| + | get-help | ||
| + | fi | ||
| + | |||
| + | # Utilisateur existant, création du dossier | ||
| + | useradd $1 -m -s /bin/bash | ||
| + | |||
| + | # Création du google authenticator | ||
| + | su -c " | ||
| + | |||
| + | # Mise à jour des droits | ||
| + | chmod 400 / | ||
| + | chmod 700 /home/${1} | ||
| + | </ | ||
| + | * On rend le script exécutable : | ||
| + | <sxh bash> | ||
| + | * On modifie le service ''/ | ||
| + | <sxh bash>sed -i ' | ||
| + | systemctl daemon-reload</ | ||
| + | * On crée la configuration PAM ''/ | ||
| + | <sxh bash>cp / | ||
| + | * On modifie cette configuration pour y ajouter en 1ère ligne : | ||
| + | < | ||
| + | * On redémarre le service : | ||
| + | <sxh bash> | ||
| + | |||
| + | Pour créer un 2FA pour un utilisateur, | ||
| - | ===== Clients ===== | + | Pour la suite, lorsque l' |
| + | ===== Clients | ||
| <callout type=" | <callout type=" | ||
| Ligne 433: | Ligne 482: | ||
| proto udp | proto udp | ||
| remote 1.2.3.4 1194 | remote 1.2.3.4 1194 | ||
| - | resolv-retry infinite | ||
| - | management 127.0.0.1 19999 | ||
| nobind | nobind | ||
| persist-key | persist-key | ||
| Ligne 440: | Ligne 487: | ||
| comp-lzo | comp-lzo | ||
| verb 4 | verb 4 | ||
| + | # uncomment below lines for use with Google 2FA | ||
| + | # | ||
| cipher AES-256-GCM | cipher AES-256-GCM | ||
| + | key-direction 1 | ||
| + | tls-client | ||
| + | remote-cert-tls server | ||
| + | auth-nocache | ||
| + | explicit-exit-notify 1 | ||
| + | reneg-sec 86400 | ||
| + | |||
| # keys | # keys | ||
| ca chemin_vers_le_fichier_ca.crt | ca chemin_vers_le_fichier_ca.crt | ||
| Ligne 446: | Ligne 502: | ||
| key chemin_vers_le_fichier_client.key | key chemin_vers_le_fichier_client.key | ||
| tls-auth chemin_vers_le_fichier_ta.key 1 | tls-auth chemin_vers_le_fichier_ta.key 1 | ||
| - | auth-nocache</ | + | </ |
| * Pour Linux, à mettre dans ''/ | * Pour Linux, à mettre dans ''/ | ||
| Ligne 458: | Ligne 514: | ||
| comp-lzo | comp-lzo | ||
| verb 4 | verb 4 | ||
| - | cipher AES-256-GCM | + | # uncomment below lines for use with Google 2FA |
| + | # | ||
| + | data-cipher AES-256-GCM | ||
| + | key-direction 1 | ||
| + | tls-client | ||
| + | remote-cert-tls server | ||
| + | auth-nocache | ||
| + | explicit-exit-notify 1 | ||
| + | reneg-sec 86400 | ||
| + | # uncomment below lines for use with linux | ||
| + | script-security 2 | ||
| + | # if you use resolved | ||
| + | #up / | ||
| + | #down / | ||
| + | # if you use systemd-resolved first install openvpn-systemd-resolved package | ||
| + | #up / | ||
| + | #down / | ||
| # keys | # keys | ||
| ca chemin_vers_le_fichier_ca.crt | ca chemin_vers_le_fichier_ca.crt | ||
| Ligne 464: | Ligne 537: | ||
| key chemin_vers_le_fichier_client.key | key chemin_vers_le_fichier_client.key | ||
| tls-auth chemin_vers_le_fichier_ta.key 1 | tls-auth chemin_vers_le_fichier_ta.key 1 | ||
| - | auth-nocache</ | + | </ |
| * Il faut ensuite inscrire le client sur le serveur, dans le dossier ''/ | * Il faut ensuite inscrire le client sur le serveur, dans le dossier ''/ | ||
| Ligne 475: | Ligne 548: | ||
| * **passerelle** : adresse du client +1 | * **passerelle** : adresse du client +1 | ||
| * **broadcast** : adresse du client +2 | * **broadcast** : adresse du client +2 | ||
| - | * les options de DHCP | + | * les options de DHCP (sauf si ajouté dans la partie serveur) |
| - | * les options de DNS | + | * les options de DNS (sauf si ajouté dans la partie serveur) |
| * les différentes routes vers les serveurs dont les accès sont autorisés | * les différentes routes vers les serveurs dont les accès sont autorisés | ||
| * Exemple : | * Exemple : | ||
| Ligne 504: | Ligne 577: | ||
| <callout type=" | <callout type=" | ||
| + | |||
| + | ===== Clients avec l' | ||
| + | |||
| + | * On se connecte à l' | ||
| + | <image shape=" | ||
| + | * Dans la fenêtre qui apparaît, on entre le nom de l' | ||
| + | <image shape=" | ||
| + | * Le compte apparaît alors en bas de la liste. On crée sa configuration de base en cliquant sur '' | ||
| + | <image shape=" | ||
| + | * Si l' | ||
| + | <image shape=" | ||
| + | * Si l' | ||
| + | <image shape=" | ||
| + | * On peut alors télécharger la configuration client en cliquant sur '' | ||
| + | <image shape=" | ||
| ~~DISCUSSION~~ | ~~DISCUSSION~~ | ||