{"id":74,"date":"2024-11-07T11:14:33","date_gmt":"2024-11-07T09:14:33","guid":{"rendered":"https:\/\/untanux.lt\/?p=74"},"modified":"2024-11-07T11:14:33","modified_gmt":"2024-11-07T09:14:33","slug":"openvpn-server-on-a-debian-server","status":"publish","type":"post","link":"https:\/\/untanux.lt\/?p=74","title":{"rendered":"OpenVPN server on a Debian server"},"content":{"rendered":"\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Step 1: Install OpenVPN Server on Debian<\/strong><br><br>    Update the package list:<br><br>sudo apt update<br><br>Install OpenVPN and additional required packages:<br><br>sudo apt install openvpn easy-rsa<br><br>Set up the Public Key Infrastructure (PKI) by navigating to the EasyRSA directory and building the CA:<br><br>make-cadir ~\/openvpn-ca<br>cd ~\/openvpn-ca<br>.\/easyrsa init-pki<br>.\/easyrsa build-ca<br><br>Generate the server certificate and key:<br><br>.\/easyrsa gen-req server nopass<br>.\/easyrsa sign-req server server<br><br>Generate client certificates, Diffie-Hellman key exchange, and HMAC key:<br><br>    .\/easyrsa gen-req client1 nopass<br>    .\/easyrsa sign-req client client1<br>    .\/easyrsa gen-dh<br>    openvpn --genkey --secret ta.key<br><br>    Copy certificates and keys to the \/etc\/openvpn\/ directory.<br><br><strong>Step 2: Configure OpenVPN to Use Azure AD for Authentication<\/strong><br><br>    Install the OpenVPN Authentication Plugin for PAM:<br><br>    sudo apt install openvpn-auth-pam<br><br>    Configure Azure AD as an authentication provider.<br><br>    Go to the Azure Portal:<br>        Navigate to Azure Active Directory > Enterprise Applications > New Application.<br>        Select Non-Gallery Application and name it OpenVPN.<br><br>    Go to Authentication and configure the redirect URIs:<br>        Add the URI: https:\/\/&lt;your-vpn-server-ip>\/auth<br>        Ensure ID tokens are enabled.<br><br>    Go to Certificates &amp; Secrets and create a Client Secret.<br><br>    Under API Permissions:<br>        Add the Microsoft Graph API permissions for User.Read.<br><br><strong>Step 3: Configure Azure AD SAML Authentication for OpenVPN<\/strong><br><br>    In Azure AD:<br>        Go to your OpenVPN app > Single sign-on > SAML.<br>        Edit the Basic SAML Configuration with the following:<br>            Identifier (Entity ID): https:\/\/&lt;your-vpn-server-ip>\/saml.<br>            Reply URL: https:\/\/&lt;your-vpn-server-ip>\/saml.<br><br>    Download the Federation Metadata XML file to use with OpenVPN.<br><br>    Configure the User Attributes &amp; Claims:<br>        Add a claim for user.userprincipalname as the NameID format.<br><br><strong>Step 4: Configure OpenVPN to Use SAML Authentication<\/strong><br><br>    On the OpenVPN server:<br>        Place the Federation Metadata XML file in the \/etc\/openvpn\/ directory.<br><br>    Edit the OpenVPN server configuration file, usually located at \/etc\/openvpn\/server.conf:<br><br>        Add the following lines to enable SAML authentication:<br><br>        plugin \/usr\/lib\/openvpn\/openvpn-plugin-auth-pam.so openvpn<br>        auth-user-pass-verify \/etc\/openvpn\/check_saml.sh via-env<br><br>    Create a check_saml.sh script to verify the SAML token.<br><strong><br>Step 5: Configure 2FA with Azure AD<\/strong><br><br>    In Azure AD, go to Security > Conditional Access:<br>        Create a new policy that requires Multi-Factor Authentication for the OpenVPN application.<br>        Set the Grant control to require Multi-Factor Authentication.<br><br>    Enable this policy to enforce 2FA for users accessing OpenVPN through Azure AD.<br><br><strong>Step 6: Restart OpenVPN and Test<\/strong><br><br>    Restart the OpenVPN service:<br><br>    sudo systemctl restart openvpn@server<br><br>    Download and configure the OpenVPN client, importing the .ovpn profile configured for SAML authentication.<br><br>    Test by logging in with an Azure AD account; you should be prompted for 2FA if configured correctly in Conditional Access.<br><br>Your OpenVPN server on Debian is now configured to authenticate users via Azure AD with 2FA enforced.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Step 1: Install OpenVPN Server on Debian Update the package list:sudo apt updateInstall OpenVPN and additional required packages:sudo apt install openvpn easy-rsaSet up the Public Key Infrastructure (PKI) by navigating to the EasyRSA directory and building the CA:make-cadir ~\/openvpn-cacd ~\/openvpn-ca.\/easyrsa init-pki.\/easyrsa build-caGenerate the server certificate and key:.\/easyrsa gen-req server nopass.\/easyrsa sign-req server serverGenerate client certificates, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/untanux.lt\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":1,"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":75,"href":"https:\/\/untanux.lt\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions\/75"}],"wp:attachment":[{"href":"https:\/\/untanux.lt\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/untanux.lt\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/untanux.lt\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}