<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Duo on The Network Stack</title>
    <link>https://thenetworkstack.com/tags/duo/</link>
    <description>Recent content in Duo on The Network Stack</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 30 Aug 2017 23:03:22 +0000</lastBuildDate>
    <atom:link href="https://thenetworkstack.com/tags/duo/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>SSH with Duo MFA and Active Directory</title>
      <link>https://thenetworkstack.com/ssh-with-duo-mfa-and-active-directory/</link>
      <pubDate>Wed, 30 Aug 2017 23:03:22 +0000</pubDate>
      <guid>https://thenetworkstack.com/ssh-with-duo-mfa-and-active-directory/</guid>
      <description>&lt;p&gt;Duo has thorough &lt;a href=&#34;https://duo.com/docs/duounix&#34;&gt;documentation&lt;/a&gt; for adding MFA to your SSH sessions, but there are a couple additional steps needed to also integrate with Active Directory. This post will go through the installation for both Duo and Active Directory for Ubuntu 16.04. For other Linux distros, the Duo documentation linked above has you covered.&lt;br&gt;
\&lt;/p&gt;
&lt;h4 id=&#34;system-components&#34;&gt;&lt;strong&gt;System components:&lt;/strong&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Ubuntu 16.04 server&lt;/li&gt;
&lt;li&gt;Duo MFA account&lt;/li&gt;
&lt;li&gt;Duo Unix package&lt;/li&gt;
&lt;li&gt;Centify Express for Active Directory integration&lt;br&gt;
\&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;duo-installation&#34;&gt;&lt;strong&gt;Duo Installation:&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;Install OpenSSL development headers and libraries:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Duo has thorough <a href="https://duo.com/docs/duounix">documentation</a> for adding MFA to your SSH sessions, but there are a couple additional steps needed to also integrate with Active Directory. This post will go through the installation for both Duo and Active Directory for Ubuntu 16.04. For other Linux distros, the Duo documentation linked above has you covered.<br>
\</p>
<h4 id="system-components"><strong>System components:</strong></h4>
<ul>
<li>Ubuntu 16.04 server</li>
<li>Duo MFA account</li>
<li>Duo Unix package</li>
<li>Centify Express for Active Directory integration<br>
\</li>
</ul>
<h4 id="duo-installation"><strong>Duo Installation:</strong></h4>
<p>Install OpenSSL development headers and libraries:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">apt-get install libssl-dev libpam-dev -y
</span></span></code></pre></div><p>Add Duo repository and install duo-unix package:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> <span class="s1">&#39;deb http://pkg.duosecurity.com/Ubuntu xenial main&#39;</span> <span class="p">|</span> tee /etc/apt/sources.list.d/duosecurity.list
</span></span><span class="line"><span class="cl">curl -s https://duo.com/APT-GPG-KEY-DUO <span class="p">|</span> apt-key add -
</span></span><span class="line"><span class="cl">apt-get update
</span></span><span class="line"><span class="cl">apt-get install duo-unix
</span></span></code></pre></div><p>Edit <strong>/etc/duo/pam_duo.conf</strong> with your integration key, secret key, and API host. You can find these values in the <a href="https://admin.duosecurity.com">Duo Administration page</a> for your &ldquo;UNIX Application&rdquo;.</p>
<pre tabindex="0"><code>[duo]
; Duo integration key
ikey = XXXXXXXXXXXXXXXXXXXXXXX
; Duo secret key
skey = XXXXXXXXXXXXXXXXXXXXXXX
; Duo API host
host = XXXXXXXXXXXXXXXXXXXXXXX
; Send command for Duo Push authentication
;pushinfo = yes
</code></pre><h4 id="centrify-installation"><strong>Centrify Installation:</strong></h4>
<p>First, edit <strong>/etc/ssh/sshd_config</strong> so that ChallengeResponseAuthentication is set to &ldquo;yes&rdquo;</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Change to yes to enable challenge-response passwords (beware issues with</span>
</span></span><span class="line"><span class="cl"><span class="c1"># some PAM modules and threads)</span>
</span></span><span class="line"><span class="cl">ChallengeResponseAuthentication yes
</span></span></code></pre></div><p>Download, unzip, and install Centrify Express:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">wget https://downloads.centrify.com/products/centrify-suite/2017-update-1/centrify-suite-2017.1-deb7-x86_64.tgz
</span></span><span class="line"><span class="cl">tar -xvzf centrify-suite-2017.1-deb7-x86_64.tgz
</span></span><span class="line"><span class="cl">./install-express.sh
</span></span></code></pre></div><p>Go through the installation script to connect to your Active Directory environment:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">You can <span class="nb">type</span> Q at any prompt to quit the installation and <span class="nb">exit</span>
</span></span><span class="line"><span class="cl">the script without making any changes to your environment.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">How <span class="k">do</span> you want to proceed? <span class="o">(</span>E<span class="p">|</span>S<span class="p">|</span>X<span class="p">|</span>C<span class="p">|</span>Q<span class="o">)</span> <span class="o">[</span>X<span class="o">]</span>: X
</span></span><span class="line"><span class="cl">Do you want to <span class="k">continue</span> to install in Express mode? <span class="o">(</span>C<span class="p">|</span>Y<span class="p">|</span>Q<span class="p">|</span>N<span class="o">)</span> <span class="o">[</span>Y<span class="o">]</span>:Y
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Do you want to run adcheck to verify your AD environment? <span class="o">(</span>Q<span class="p">|</span>Y<span class="p">|</span>N<span class="o">)</span> <span class="o">[</span>Y<span class="o">]</span>:Y
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Please enter the Active Directory domain to check <span class="o">[</span>company.com<span class="o">]</span>: your-domain.com
</span></span><span class="line"><span class="cl">Join an Active Directory domain? <span class="o">(</span>Q<span class="p">|</span>Y<span class="p">|</span>N<span class="o">)</span> <span class="o">[</span>Y<span class="o">]</span>:Y
</span></span><span class="line"><span class="cl">    Enter the Active Directory domain to join <span class="o">[</span>your-domain.com<span class="o">]</span>:
</span></span><span class="line"><span class="cl">    Enter the Active Directory authorized user <span class="o">[</span>administrator<span class="o">]</span>: your-admin
</span></span><span class="line"><span class="cl">    Enter the password <span class="k">for</span> the Active Directory user:
</span></span><span class="line"><span class="cl">    Enter the computer name <span class="o">[</span>server-name<span class="o">]</span>:
</span></span><span class="line"><span class="cl">    Enter the container DN <span class="o">[</span>Computers<span class="o">]</span>:
</span></span><span class="line"><span class="cl">    Enter the name of the domain controller <span class="o">[</span>auto detect<span class="o">]</span>:
</span></span><span class="line"><span class="cl">Reboot the computer after installation? <span class="o">(</span>Q<span class="p">|</span>Y<span class="p">|</span>N<span class="o">)</span> <span class="o">[</span>Y<span class="o">]</span>: Y
</span></span></code></pre></div><p>After the server restarts, you should be able to login with your Active Directory credentials via SSH, but you are not prompted for Duo MFA. To support this, we need to edit <strong>/etc/pam.d/common-auth</strong> as follows:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># lines inserted by Centrify Direct Control { CentrifyDC 5.4.1-455 }</span>
</span></span><span class="line"><span class="cl"><span class="c1">#auth   sufficient      pam_centrifydc.so</span>
</span></span><span class="line"><span class="cl"><span class="c1">#auth   requisite       pam_centrifydc.so deny</span>
</span></span><span class="line"><span class="cl">auth    requisite       pam_centrifydc.so
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># here are the per-package modules (the &#34;Primary&#34; block)</span>
</span></span><span class="line"><span class="cl"><span class="c1">#auth   [success=1 default=ignore]      pam_unix.so nullok_secure</span>
</span></span><span class="line"><span class="cl">auth    requisite       pam_unix.so nullok_secure
</span></span><span class="line"><span class="cl">auth  <span class="o">[</span><span class="nv">success</span><span class="o">=</span><span class="m">1</span> <span class="nv">default</span><span class="o">=</span>ignore<span class="o">]</span> /lib64/security/pam_duo.so
</span></span></code></pre></div><p>In both sections, I commented out the existing config and added the necessary lines so that pam_duo is used after a successful pam_centrifydc authentication.</p>
<p>Next, we need to edit <strong>/etc/pam.d/sshd</strong> and comment out &ldquo;@include common-auth&rdquo; so we can add the Centrify and Duo PAM modules (but we don&rsquo;t need pam_unix):</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Standard Un*x authentication.</span>
</span></span><span class="line"><span class="cl"><span class="c1">#@include common-auth</span>
</span></span><span class="line"><span class="cl">auth    requisite       pam_centrifydc.so
</span></span><span class="line"><span class="cl">auth    <span class="o">[</span><span class="nv">success</span><span class="o">=</span><span class="m">1</span> <span class="nv">default</span><span class="o">=</span>ignore<span class="o">]</span>      /lib64/security/pam_duo.so
</span></span><span class="line"><span class="cl">auth    requisite       pam_deny.so
</span></span><span class="line"><span class="cl">auth    required        pam_permit.so
</span></span></code></pre></div><p>You should be able to SSH to the server with your Active Directory credentials, and then be prompted for Duo MFA (assuming you have a Duo account that matches your AD username)<br>
\</p>
<h4 id="active-directory-group-restriction"><strong>Active Directory Group Restriction:</strong></h4>
<p>You may also want to restrict SSH access to users in a certain Active Directory group. This can be done with two lines in <strong>/etc/ssh/sshd_config</strong> at the end of the config, after &ldquo;UsePAM yes&rdquo;:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">UsePAM yes
</span></span><span class="line"><span class="cl"><span class="c1">#########</span>
</span></span><span class="line"><span class="cl">UseDNS no
</span></span><span class="line"><span class="cl">AllowGroups root your-group-name
</span></span></code></pre></div><p>Be sure to add the &lsquo;root&rsquo; group so that you can still manage your server with the root account if needed. Restart SSH and your group restriction will be in effect:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">service ssh restart
</span></span></code></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>ADFS MFA with Office 365</title>
      <link>https://thenetworkstack.com/adfs-mfa-with-office-365/</link>
      <pubDate>Sat, 27 May 2017 01:06:39 +0000</pubDate>
      <guid>https://thenetworkstack.com/adfs-mfa-with-office-365/</guid>
      <description>&lt;p&gt;We wanted to implement MFA (multi-factor authentication) for our ADFS servers when authenticating to Office 365.  If you just want basic “MFA for all users” then the AD FS GUI will allow you to select your MFA provider and enable.  I needed a more granular policy:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Only enable MFA if the user is a member of a specific security group &lt;strong&gt;AND&lt;/strong&gt; the user is coming from outside the corporate network &lt;strong&gt;AND&lt;/strong&gt; it is a browser based authentication request&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;</description>
      <content:encoded><![CDATA[<p>We wanted to implement MFA (multi-factor authentication) for our ADFS servers when authenticating to Office 365.  If you just want basic “MFA for all users” then the AD FS GUI will allow you to select your MFA provider and enable.  I needed a more granular policy:</p>
<blockquote>
<p><em>Only enable MFA if the user is a member of a specific security group <strong>AND</strong> the user is coming from outside the corporate network <strong>AND</strong> it is a browser based authentication request</em></p>
</blockquote>
<p>The third part of that policy is in place so that a user can still use activesync or skype for business, since they do not support MFA (or microsoft modern authentication) right now.</p>
<p>Granular ADFS policies are set using “claims”, which can be combined together with “&amp;&amp;” statements.  Here are the three claims I needed enabled:</p>
<p><em>Only enable MFA for members of a security group (use your own group SID in <strong>Value == &quot; &ldquo;</strong>)</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">c:[Type == “http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid&amp;#8221;, Value == “S-1-2-46-1537777264-XXXXXXXXXXXXX”] &amp;&amp;
</span></span></code></pre></div><p><em>Only enable MFA for users outside the corporate network (auth requests that go through the AD FS web proxy)</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">c1:[Type == “http://schemas.microsoft.com/ws/2012/01/insidecorporatenetwork&amp;#8221;, Value == “false”] &amp;&amp;
</span></span></code></pre></div><p><em>Only enable MFA for browser based requests</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">c2:[Type == “http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-endpoint-absolute-path&amp;#8221;, Value =~ “(/adfs/ls)|(/adfs/oauth2)”]
</span></span></code></pre></div><h3 id="configuration"><strong>Configuration</strong></h3>
<p>To apply these claims, first enable the MFA provider using the GUI.  Open AD FS, click on “Authentication Policies” and then click “Edit Global Multi-Factor Authentication” on the left-hand side.  From there you can select your MFA provider and click “Apply”.  After this, you must use powershell.  I also used powershell variables to make the process a little cleaner.</p>
<p>First, the <strong>$mfarule</strong> variable contains all three claims above, joined together with <strong>&amp;&amp;</strong>:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">PS C:\windows\system32&gt; $mfarule=&#39;c:[Type == &#34;http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid&#34;, Value == &#34;S-1-2-46-1537777264-XXXXXXXXXXXXX&#34;] &amp;&amp; c1:[Type == &#34;http://schemas.microsoft.com/ws/2012/01/insidecorporatenetwork&#34;, Value == &#34;false&#34;] &amp;&amp; c2:[Type == &#34;http://schemas.microsoft.com/2012/01/requestcontext/claims/x-ms-endpoint-absolute-path&#34;, Value =~ &#34;(/adfs/ls)|(/adfs/oauth2)&#34;] =&gt; issue(Type = &#34;http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod&#34;, Value = &#34;http://schemas.microsoft.com/claims/multipleauthn&#34;);&#39;
</span></span></code></pre></div><p>Second, we set the <strong>$rpt</strong> variable with the name of the Relying Party Trust that needs MFA.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">PS C:\windows\system32&gt; $rpt = Get-AdfsRelyingPartyTrust –Name &#34;Microsoft Office 365 Identity Platform&#34;
</span></span></code></pre></div><p>Last, we use both the variables we defined before and set the MFA rule.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">PS C:\windows\system32&gt; Set-AdfsRelyingPartyTrust –TargetRelyingParty $rpt –AdditionalAuthenticationRules $mfarule
</span></span></code></pre></div><p>And now you are done!  The following command reverts the changes made back to default:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">PS C:\windows\system32&gt; Set-AdfsRelyingPartyTrust –TargetRelyingParty $rpt –AdditionalAuthenticationRules &#39;&#39;
</span></span></code></pre></div><h3 id="additional-commands"><strong>Additional Commands</strong></h3>
<p>The commands above enable MFA just for the Office 365 relying party (so I can have different policies per party).  If you would like to enable these settings on a global scale, use this:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">PS C:\windows\system32&gt; Set-AdfsAdditionalAuthenticationRule -AdditionalAuthenticationRules $mfarule
</span></span></code></pre></div><p>And finally, to see all your changes made:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">PS C:\windows\system32&gt; Get-AdfsRelyingPartyTrust -Name DisplayNameofRelyingTrust
</span></span></code></pre></div><hr>
<p>These blogs were extremely helpful throughout this process:</p>
<p><a href="https://doubledit.co.uk/2015/10/21/adfs-multi-factor-authentication-force-mfa-for-browser-based-access-to-office-365/">https://doubledit.co.uk/2015/10/21/adfs-multi-factor-authentication-force-mfa-for-browser-based-access-to-office-365/</a></p>
<p><a href="http://blog.auth360.net/2014/10/23/mfa-conditional-access-policies-in-ad-fs-2012-r2/">http://blog.auth360.net/2014/10/23/mfa-conditional-access-policies-in-ad-fs-2012-r2/</a></p>
<p><a href="http://blogs.msdn.com/b/ramical/archive/2014/01/30/under-the-hood-tour-on-multi-factor-authentication-in-ad-fs-part-1-policy.aspx">http://blogs.msdn.com/b/ramical/archive/2014/01/30/under-the-hood-tour-on-multi-factor-authentication-in-ad-fs-part-1-policy.aspx</a></p>
<p><a href="https://technet.microsoft.com/en-us/library/dn479343(v=wps.630).aspx">https://technet.microsoft.com/en-us/library/dn479343(v=wps.630).aspx</a></p>
]]></content:encoded>
    </item>
  </channel>
</rss>
