2FA https://bgmot.com/ en Zabbix: two-factor authentication with Authenticator app (version 5.0.10+, 6.0, 6.4) https://bgmot.com/zabbix_twofa_gglauth <span>Zabbix: two-factor authentication with Authenticator app (version 5.0.10+, 6.0, 6.4)</span> <div class="field field--name-field-author field--type-string field--label-inline"> <div class="field--label">Author</div> <div class="field--item">Evgeny Yurchenko</div> </div> <span><span>ey</span></span> <span><time datetime="2021-04-28T09:06:40+07:00" title="Wednesday, April 28, 2021 - 09:06">Wed, 04/28/2021 - 09:06</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>This article describes how to implement two-factor authentication (2FA) in Zabbix server with Google or Microsoft Authenticator app (available for iOS and Android).</p> <p>You can find many articles about how Authenticator app works on the Internet let's briefly describe how it applies to Zabbix server. When a user logs in and Zabbix server successfully authenticates him/her using one of its "out-of-the-box" methods (Internal, LDAP, etc) then 2FA via Authenticator app takes place and only if this user successfully enters one time password (OTP) generated on his/her device by Authenticator app only then the user is granted access to Zabbix server WebUI. This algorithm is implemented in <strong>non-official</strong> fork of Zabbix server <a href="https://github.com/BGmot/zabbix">https://github.com/BGmot/zabbix</a> (see README about different ways to install it).</p> <p>There are two ways to install/test this feature.</p> <p><strong>1) </strong>The easiest way to test this solution is to deploy these docker container (if you don't want to touch your Zabbix server instance):</p> <pre> <code class="language-bash">docker run -p 8080:80 --name zabbix-appliance -t -d bgmot42/zabbix-appliance-ubuntu:6.0.0-bg</code></pre> <p>Bringing up zabbix-appliance container takes time as it creates the database schema from scratch, before proceeding watch its logs:</p> <pre> <code class="language-bash">docker logs -f zabbix-appliance</code></pre> <p>and do not proceed until you see that all zabbix-server processes started:</p> <pre> <code class="language-bash"> 377:20210428:014731.172 server #40 started [lld worker #1] 378:20210428:014731.174 server #41 started [lld worker #2] 372:20210428:014731.233 server #36 started [preprocessing worker #1] 374:20210428:014731.233 server #38 started [preprocessing worker #3] 373:20210428:014731.249 server #37 started [preprocessing worker #2] </code></pre> <p><strong>2) </strong>Install the feature on you already running Zabbix server (hope you know what you are doing). Login into the server and do the following:</p> <pre> <code class="language-bash">curl -L -o bg-features-install.sh https://github.com/BGmot/zabbix/raw/6.0.0-bg/bg-scripts/bg-features-install.sh</code></pre> <p>Then edit bg-features-install.sh to provide correct values for these variables:</p> <pre> <code class="language-bash">DB_HOST=localhost DB_USERNAME=zabbix DB_PASSWORD=zabbix ZABBIX_INSTALL_PATH=/usr/share/zabbix</code></pre> <p>and run installations script which will make some additions to DB and replace some php files (current files will be backed up):</p> <pre> <code class="language-bash">sudo bash bg-features-install.sh</code></pre> <p>If you see "<span>Done! Reload your browser to see changes." then patching completed successfully you can proceed.</span></p> <h2><strong>Turn on 2FA</strong></h2> <p>So you have a running Zabbix server with default user "Admin" and password "zabbix". Go to <span>http://localhost:8080/ URL and login with these credentials.</span> Open <em>Administration</em> <em>-&gt; 2FA</em> page, select <em>Google Authenticator</em> and click <em>Update</em>.</p> <img alt="Zabbix 2FA Google authenticator on" data-entity-type="file" data-entity-uuid="2f0e0fba-9223-40fd-a2e0-aaf9e639ce93" src="/sites/default/files/inline-images/zabbix-2fa-on.png" class="align-center" width="948" height="470" loading="lazy" /><p>Log off and try to login as "Admin" again.</p> <h2><strong>Registering your device</strong></h2> <p>If you (user Admin) have never logged in using Google Authenticator Zabbix will generate unique secret code for this account and you'll be presented with a QR code representing this code:</p> <img alt="Zabbix 2FA Google enrollment" data-entity-type="file" data-entity-uuid="eb0ba016-1664-4dca-8d01-6e5394826749" src="/sites/default/files/inline-images/zabbix-2fa-ggl-enrollment.png" class="align-center" width="407" height="636" loading="lazy" /><p>Open Google Authenticator app on your device, tap plus sign and scan this QR code. You should see "Zabix docker (Admin)" entry in the app:<br />  </p> <img alt="Google Authenticator device enrolled" data-entity-type="file" data-entity-uuid="b5fe5557-d456-4b3a-aaee-9084fcdc9304" src="/sites/default/files/inline-images/zabbix-2fa-ggl-phone-enrolled.png" class="align-center" width="500" height="889" loading="lazy" /><p>Enter these 6 digits into Zabbix UI prompt and if you did everything correctly you'll see default UI page and Zabbix internally will update Admin user's status to 'Enrolled into Google authenticator 2FA' so nobody will ever see this QR code again. It's important to know that the secret code generated once during user's registration will never travels to user's browser so can't be intercepted. When in future Admin user logs in again into Zabbix his/her enrollment status will be checked and only request for 6-digit code will be shown:</p> <img alt="Zabbix 2FA Google Authenticator enrolled" data-entity-type="file" data-entity-uuid="cf3f8ca3-da5f-46c2-b432-de14579a83aa" src="/sites/default/files/inline-images/zabbix-2fa-ggl-enrolled.png" class="align-center" width="407" height="350" loading="lazy" /><p> </p></div> <p></p> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <span class="field--label">Tags</span>:&nbsp; <a href="/taxonomy/term/17" hreflang="en">Zabbix</a>&nbsp; <a href="/taxonomy/term/18" hreflang="en">2FA</a>&nbsp; </div> <div class="user-comment-area pt-50"> </div> Wed, 28 Apr 2021 02:06:40 +0000 ey 93 at https://bgmot.com Zabbix: two-factor authentication with DUO https://bgmot.com/zabbix_twofa_duo <span>Zabbix: two-factor authentication with DUO</span> <div class="field field--name-field-author field--type-string field--label-inline"> <div class="field--label">Author</div> <div class="field--item">Evgeny Yurchenko</div> </div> <span><span>ey</span></span> <span><time datetime="2021-02-17T10:35:38+07:00" title="Wednesday, February 17, 2021 - 10:35">Wed, 02/17/2021 - 10:35</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>This article describes how to implement 2FA with DUO as provider in Zabbix server.</p> <p>If you are not familiar with two-factor authentication then please read <a href="https://duo.com/product/multi-factor-authentication-mfa/two-factor-authentication-2fa">this nice introduction</a>. Why DUO? Because at the moment of when this requirement for Zabbix server came up I was working for a company that used DUO 2FA for all services access.</p> <p>What's added to Zabbix server - when a user logs in and Zabbix server successfully authenticates him/her then 2FA via DUO takes place and only if this users successfully authenticated by DUO he/she is granted access to Zabbix server WebUI. This algorithm is implemented in <strong>non-official</strong> fork of Zabbix server <a href="https://github.com/BGmot/zabbix">https://github.com/BGmot/zabbix</a> (see README about different ways to install it). You can read about how Zabbix server interacts with DUO <a href="https://duo.com/docs/duoweb">here</a>.</p> <p>The easiest way to test this solution is to deploy these docker container (if you don't want to touch your Zabbix server instance):</p> <pre> <code class="language-bash">docker run -p 8080:80 --name zabbix-appliance -t -d bgmot42/zabbix-appliance-ubuntu:6.0.0-bg</code></pre> <p>But before we can test anything you need to set up your DUO account.</p> <h2><strong>Setting up DUO</strong></h2> <p>It's very nice of DUO to offer absolutely free not limited by time access to DUO services for up to 10 users so go <a href="https://duo.com/pricing/duo-free">here</a> and create an account. Login into your 'Dashboard' and select <em>Applications</em> at the left menu, click <em>Protect an Application</em> button. In <em>Protect an Application</em> field put <em>web sdk</em> to filter all the results.</p> <img alt="DUO protect an application" data-entity-type="file" data-entity-uuid="33d74249-0606-4aa0-a38b-786fd5aa5c5f" src="/sites/default/files/inline-images/duo_protect_an_application.png" class="align-center" /><p>Click on <em>Protect</em> button in <em>Web SDK</em> line and you'll be forwarded to a page with your <em>Web SDK</em> application settings:</p> <img alt="DUO Web SDK application" data-entity-type="file" data-entity-uuid="b7c51bc2-5565-436c-a648-8a3654a4ecf5" src="/sites/default/files/inline-images/duo_web_sdk_settings.png" class="align-center" /><p>In the next step we will be using these values to configure DUO 2FA in Zabbix server.</p> <h2><strong>Configure Zabbix server</strong></h2> <p>Login into Zabbix WebUI as Admin (if you started container as described above then URL is http://192.168.0.102:8080.</p> <p>Create a test user if you don't have it already (for demo in this howto <em>bgmot</em> user was created).</p> <p>Go to <em>Administration -&gt; 2FA</em>, select DUO and fill <em>API hostname</em>, <em>Integration key</em> and <em>Secret key</em> fields copy-pasting from DUO WebSDK settings. There are two ways to generate <em>40 characters long custom key</em>:</p> <ol><li>Use this on-line service http://www.sha1-online.com/ and generate 40 characters SHA1 key.</li> <li>Login into any server that has Python installed and execute: <pre> <code class="language-python">import os, hashlib print hashlib.sha1(os.urandom(32)).hexdigest()</code></pre> </li> </ol><p>So you should have something similar to this in Zabbix server WebUI:</p> <img alt="Zabbix DUO settings" data-entity-type="file" data-entity-uuid="e7c72173-d85f-446f-9f4c-8af64fd16438" src="/sites/default/files/inline-images/zabbix_duo_settings.png" class="align-center" /><p> </p> <p>Click Update and the Zabbix server is configured for 2FA!</p> <h2><strong>Testing</strong></h2> <p>Logout out of Zabbix WebUI and login back as a test user, if you entered credentials correctly you'll see DUO's set up page, this means the user has not been set up yet at DUO side.</p> <img alt="Zabbix DUO account set up" data-entity-type="file" data-entity-uuid="bdb0b8d7-29d4-4c1a-a312-f1b6ca07cec4" src="/sites/default/files/inline-images/zabbix_duo_account_setup.png" class="align-center" /><p> </p> <p>Click <em>Start setup</em>. Select type of device you are going to use for 2FA and answer all other questions, finally you should see this screen:<br />  </p> <img alt="Zabbix DUO enrollment successful" data-entity-type="file" data-entity-uuid="00c54d14-6703-4481-9d90-a8aeb6238cc2" src="/sites/default/files/inline-images/zabbix_duo_enrollment_successful.png" class="align-center" /><p> </p> <p>Select the way you want to perform 2FA and authorize accordingly. That's it now you are authorized and should be redirected to <em>Dashboards</em> in Zabbix WebUI. The next time you login you will not need to go through set up process you will only need to select the way to perform 2FA and confirm authentication on your device.</p> <p>Now if you go back to your Dashboard in DUO and select Users you'll see that new user bgmot has been created. Here you can disable 2FA for this user, disable user effectively disabling his/her access to Zabbix, see timeline when this user logged in and do lots of other cool stuff (read DUO's documentation).</p></div> <p></p> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <span class="field--label">Tags</span>:&nbsp; <a href="/taxonomy/term/17" hreflang="en">Zabbix</a>&nbsp; <a href="/taxonomy/term/18" hreflang="en">2FA</a>&nbsp; <a href="/taxonomy/term/21" hreflang="en">DUO</a>&nbsp; </div> <div class="user-comment-area pt-50"> </div> Wed, 17 Feb 2021 03:35:38 +0000 ey 82 at https://bgmot.com