<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AD &#8211; Blog of Kliment Andreev &#8211; A place so I won&#039;t forget things</title>
	<atom:link href="https://blog.andreev.it/tag/ad/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.andreev.it</link>
	<description></description>
	<lastBuildDate>Sat, 24 Oct 2020 13:16:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>AWS, OKTA: Single sign-on in AWS Console using OKTA and on-prem Active Directory (AD)</title>
		<link>https://blog.andreev.it/2020/02/aws-okta-single-sign-on-in-aws-console-using-okta-and-on-prem-active-directory-ad/</link>
					<comments>https://blog.andreev.it/2020/02/aws-okta-single-sign-on-in-aws-console-using-okta-and-on-prem-active-directory-ad/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Sun, 16 Feb 2020 20:33:31 +0000</pubDate>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[OKTA]]></category>
		<category><![CDATA[SSO]]></category>
		<guid isPermaLink="false">https://blog.andreev.it/?p=6483</guid>

					<description><![CDATA[AWS Console has its own authentication/authorization directory using IAM users, roles and policies. On&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>AWS Console has its own authentication/authorization directory using IAM users, roles and policies. On top of that, they also offer multi-factor authentication, so your logins are much more secure. But, I wanted to see how I can use Okta for SSO between my AD domain at home and AWS. The setup is very simple as you can see from this diagram.<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-01.png"><img fetchpriority="high" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-01.png" alt="" width="1778" height="1174" class="aligncenter size-full wp-image-6486" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-01.png 1778w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-01-300x198.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-01-1024x676.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-01-768x507.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-01-1536x1014.png 1536w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-01-1170x773.png 1170w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-01-780x516.png 780w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-01-585x386.png 585w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-01-263x175.png 263w" sizes="(max-width: 1778px) 100vw, 1778px" /></a><br />
On the left side, AWS is missing &#8211; but you get the point. In my case, I&#8217;ll have two AD groups, <strong>AWS Full Admin</strong> and <strong>AWS Read Only</strong>. I also have two AD users, <strong>admin.user</strong> and <strong>ro.user</strong>. If you haven&#8217;t integrated your AD with Okta it&#8217;s time to do so. </p>
<h1>Okta</h1>
<p>Go to the Okta dashboard and from the menu go to <strong>Directory | Directory Integrations</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-02.png"><img decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-02.png" alt="" width="742" height="500" class="aligncenter size-full wp-image-6490" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-02.png 742w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-02-300x202.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-02-585x394.png 585w" sizes="(max-width: 742px) 100vw, 742px" /></a><br />
Click on <strong>Add Active Directory</strong> and proceed so you can download an agent that you have to install on a member server with at least 8GB RAM. You can also install it on a domain controller, which I did in my lab, but I guess it&#8217;s not recommended. You&#8217;ll see this page telling you that Okta is waiting for your AD to connect.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-03.png"><img decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-03.png" alt="" width="955" height="501" class="aligncenter size-full wp-image-6491" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-03.png 955w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-03-300x157.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-03-768x403.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-03-585x307.png 585w" sizes="(max-width: 955px) 100vw, 955px" /></a><br />
Go ahead and install the agent. You&#8217;ll be prompted to specify the domain name (<strong>andreev.local</strong> in my case), create a service account <strong>OktaService </strong>or choose an existing one, choose a proxy to connect to Okta servers over HTTPS (if needed) and finally you have to specify your Okta domain, e.g. the prefix for your Okta landing page, https://company.Okta.com. You have to type -company-.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-04.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-04.png" alt="" width="481" height="339" class="aligncenter size-full wp-image-6492" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-04.png 481w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-04-300x211.png 300w" sizes="(max-width: 481px) 100vw, 481px" /></a><br />
Once the service starts and authenticates with your Okta admin account to the Okta servers, your dashboard page will change asking you to specify what OUs in your AD you want to sync. Choose the OUs and choose your Okta username format.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-05.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-05.png" alt="" width="915" height="856" class="aligncenter size-full wp-image-6493" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-05.png 915w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-05-300x281.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-05-768x718.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-05-585x547.png 585w" sizes="(max-width: 915px) 100vw, 915px" /></a><br />
In my case I&#8217;ll use UPN which is <strong>username@andreev.local</strong>, but you can choose e-mail if your have a valid e-mail specified for the users, e.g. <strong>username@google.com</strong> or the SAM account which is your login that you use for AD, e.g. <strong>username</strong>. See below.<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-06.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-06.png" alt="" width="395" height="327" class="aligncenter size-full wp-image-6497" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-06.png 395w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-06-300x248.png 300w" sizes="(max-width: 395px) 100vw, 395px" /></a><br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-07.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-07.png" alt="" width="393" height="172" class="aligncenter size-full wp-image-6498" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-07.png 393w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-07-300x131.png 300w" sizes="(max-width: 393px) 100vw, 393px" /></a><br />
Click <strong>Next </strong>and unless you have some non-standard AD attributes that you want to map, it&#8217;s safe to proceed with the defaults. Under the settings for the AD in Okta, you can choose the scheduled interval for the AD sync. By default, this sync is disabled. To test the integration, go to the settings page of your AD in Okta, choose <strong>Test Delegated Authentication</strong> (bottom right) and enter the username and password for an AD account that you know it&#8217;s synced with Okta.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-08.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-08.png" alt="" width="1077" height="687" class="aligncenter size-full wp-image-6500" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-08.png 1077w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-08-300x191.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-08-1024x653.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-08-768x490.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-08-585x373.png 585w" sizes="(max-width: 1077px) 100vw, 1077px" /></a><br />
You can also test the integration if you go to https://-company-.okta.com and log in with a synced AD user. </p>
<h2>Okta app for AWS</h2>
<p>Before we move to AWS part, click on <strong>Applications </strong>from the menu and click on <strong>Add Application</strong> menu. Type <strong>Amazon Web Services</strong> and select the app. Do not use AWS Console app, that&#8217;s a different one.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-09.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-09.png" alt="" width="764" height="353" class="aligncenter size-full wp-image-6503" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-09.png 764w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-09-300x139.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-09-585x270.png 585w" sizes="(max-width: 764px) 100vw, 764px" /></a><br />
Click <strong>Add </strong>and you can leave the settings under <strong>General Settings</strong> or change it to AWS Console. Click <strong>Next </strong>and on the next screen, use <strong>SAML 2.0</strong><br />
Click on the <strong>Identity Provider Metadata</strong> link and download the file. You&#8217;ll need this for later.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-10.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-10.png" alt="" width="680" height="313" class="aligncenter size-full wp-image-6505" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-10.png 680w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-10-300x138.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-10-585x269.png 585w" sizes="(max-width: 680px) 100vw, 680px" /></a><br />
Click <strong>Done </strong>and once this part is completed, we can go to AWS Console and configure AWS IAM and then come back to Okta. </p>
<h1>AWS Console</h1>
<p>Log to the AWS Console with an account with sufficient rights to create IAM polices, roles and users. Go to <strong>IAM </strong>and then <strong>Identity Providers</strong> on the left side. Click <strong>Create Provider</strong> and choose <strong>SAML </strong>for <strong>Provider Type</strong>, type a description (e.g. <strong>OKTA</strong>) and choose the <strong>metadata </strong>file that you&#8217;ve just downloaded.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-11.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-11.png" alt="" width="563" height="255" class="aligncenter size-full wp-image-6506" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-11.png 563w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-11-300x136.png 300w" sizes="(max-width: 563px) 100vw, 563px" /></a><br />
Click on<strong> Next Step</strong> and then <strong>Create</strong>. Click on the entry that you just created and make a note of the ARN. You&#8217;ll need this later.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-12.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-12.png" alt="" width="657" height="239" class="aligncenter size-full wp-image-6507" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-12.png 657w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-12-300x109.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-12-585x213.png 585w" sizes="(max-width: 657px) 100vw, 657px" /></a></p>
<h2>IAM</h2>
<p>We&#8217;ll create two new roles based on existing AWS policies for full admin access and read only access. Go to <strong>IAM </strong>| <strong>Roles</strong> and click on <strong>Create Role</strong>. Click on <strong>SAML 2.0 federation</strong>, choose the <strong>SAML </strong>provider that we just created, select <strong>Allow programmatic and AWS Management Console</strong> access and click on <strong>Next: Permissions</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-13.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-13.png" alt="" width="1007" height="819" class="aligncenter size-full wp-image-6509" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-13.png 1007w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-13-300x244.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-13-768x625.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-13-585x476.png 585w" sizes="(max-width: 1007px) 100vw, 1007px" /></a><br />
You can create your own policy if you want by clicking on <strong>Create policy</strong> or choose an existing one like I did by filtering the <strong>Read Only</strong> policies. Click on <strong>Next: Tags</strong> after.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-14.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-14.png" alt="" width="1027" height="809" class="aligncenter size-full wp-image-6510" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-14.png 1027w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-14-300x236.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-14-1024x807.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-14-768x605.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-14-585x461.png 585w" sizes="(max-width: 1027px) 100vw, 1027px" /></a><br />
You can tag your role and click <strong>Next: Review</strong> after&#8230;and finally you can create the role.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-16.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-16.png" alt="" width="1033" height="792" class="aligncenter size-full wp-image-6511" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-16.png 1033w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-16-300x230.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-16-1024x785.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-16-768x589.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-16-585x449.png 585w" sizes="(max-width: 1033px) 100vw, 1033px" /></a><br />
Do the same again <strong>IAM | Roles | SAML</strong>, but this time create a full admin role named <strong>rolFullAdminAccess </strong>(filter the policies by <strong>Administrator</strong>).<br />
Let&#8217;s connect AWS and Okta now, but creating a user that will be able to list the roles. Go to <strong>IAM | User</strong> and click on <strong>Add user</strong>. Name your user and allow <strong>Programmatic access</strong> only.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-17.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-17.png" alt="" width="889" height="490" class="aligncenter size-full wp-image-6513" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-17.png 889w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-17-300x165.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-17-768x423.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-17-585x322.png 585w" sizes="(max-width: 889px) 100vw, 889px" /></a><br />
Click on <strong>Create policy</strong>. This will open a new window. Do not close the previous one.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-18.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-18.png" alt="" width="769" height="249" class="aligncenter size-full wp-image-6514" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-18.png 769w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-18-300x97.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-18-585x189.png 585w" sizes="(max-width: 769px) 100vw, 769px" /></a><br />
Click on the <strong>JSON </strong>tab and paste this policy. Then click <strong>Review policy</strong>.</p>
<pre class="brush: xml; title: ; notranslate">
{
    &quot;Version&quot;: &quot;2012-10-17&quot;,
    &quot;Statement&quot;: &#x5B;
        {
          &quot;Effect&quot;: &quot;Allow&quot;,
          &quot;Action&quot;: &#x5B;
              &quot;iam:ListRoles&quot;,
              &quot;iam:ListAccountAliases&quot;
          ],
          &quot;Resource&quot;: &quot;*&quot;
        }
    ]
}
</pre>
<p>Name your policy and click on <strong>Create policy</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-19.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-19.png" alt="" width="1214" height="592" class="aligncenter size-full wp-image-6517" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-19.png 1214w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-19-300x146.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-19-1024x499.png 1024w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-19-768x375.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-19-1170x571.png 1170w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-19-585x285.png 585w" sizes="(max-width: 1214px) 100vw, 1214px" /></a><br />
Go back to the previous tab and click on the refresh button, right off the <strong>Create policy</strong> button. Then filter the policy and assign it. Click <strong>Next: Tags</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-20.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-20.png" alt="" width="1004" height="241" class="aligncenter size-full wp-image-6518" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-20.png 1004w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-20-300x72.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-20-768x184.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-20-585x140.png 585w" sizes="(max-width: 1004px) 100vw, 1004px" /></a><br />
Proceed to create the user, but make sure you download the CSV file with the credentials for this user.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-21.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-21.png" alt="" width="1003" height="191" class="aligncenter size-full wp-image-6520" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-21.png 1003w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-21-300x57.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-21-768x146.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-21-585x111.png 585w" sizes="(max-width: 1003px) 100vw, 1003px" /></a></p>
<h1>Okta &#8211; app config</h1>
<p>Go back to Okta and click on the<strong> Sign On</strong> tab and then <strong>Edit</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-22.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-22.png" alt="" width="748" height="283" class="aligncenter size-full wp-image-6522" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-22.png 748w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-22-300x114.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-22-585x221.png 585w" sizes="(max-width: 748px) 100vw, 748px" /></a><br />
Scroll down a little bit and paste your ARN value (the one that you got from AWS earlier) under <strong>Identity Provider ARN (Required only for SAML SSO</strong>. It&#8217;s under <strong>IAM | Providers | -your-provider</strong> in AWS. Click <strong>Save</strong> after.<br />
Click on the <strong>Provisioning </strong>tab next to <strong>Sign On</strong> and click on <strong>Configure API Integration</strong>. Click the checkmark, then copy and paste the access key and the secret from the CSV file from AWS. Click Test API Credentials and if everything is OK, click on Save.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-24.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-24.png" alt="" width="803" height="411" class="aligncenter size-full wp-image-6524" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-24.png 803w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-24-300x154.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-24-768x393.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-24-585x299.png 585w" sizes="(max-width: 803px) 100vw, 803px" /></a><br />
Under <strong>Provisioning </strong>make sure that <strong>Create Users</strong> and <strong>Update User Attributes</strong> are enabled.<br />
Finally, go to the <strong>Assignments </strong>tab and select <strong>Groups</strong>. Then, click the green button <strong>Assign </strong>and choose <strong>Assign to Groups</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-26.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-26.png" alt="" width="598" height="399" class="aligncenter size-full wp-image-6527" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-26.png 598w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-26-300x200.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-26-585x390.png 585w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-26-263x175.png 263w" sizes="(max-width: 598px) 100vw, 598px" /></a><br />
You will see your groups here, select the first one and click the <strong>Assign </strong>button.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-27.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-27.png" alt="" width="630" height="608" class="aligncenter size-full wp-image-6528" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-27.png 630w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-27-300x290.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-27-585x565.png 585w" sizes="(max-width: 630px) 100vw, 630px" /></a><br />
You will see your roles there. Select the admin role and Save.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-28.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-28.png" alt="" width="616" height="581" class="aligncenter size-full wp-image-6529" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-28.png 616w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-28-300x283.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-28-585x552.png 585w" sizes="(max-width: 616px) 100vw, 616px" /></a><br />
Do the same for the other group and role and pretty much you are all set. Open a new browser and this time log as one of the users, in my case I am logging as admin.user to https://mycompany.okta.com.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-29.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-29.png" alt="" width="697" height="686" class="aligncenter size-full wp-image-6531" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-29.png 697w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-29-300x295.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-29-585x576.png 585w" sizes="(max-width: 697px) 100vw, 697px" /></a><br />
You&#8217;ll get a note that you have a new app assigned.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-30.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-30.png" alt="" width="764" height="365" class="aligncenter size-full wp-image-6532" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-30.png 764w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-30-300x143.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-30-585x279.png 585w" sizes="(max-width: 764px) 100vw, 764px" /></a><br />
If you click on the app icon, you&#8217;ll get logged in to the AWS console without any passwords.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-31.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-31.png" alt="" width="933" height="473" class="aligncenter size-full wp-image-6533" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-31.png 933w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-31-300x152.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-31-768x389.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-31-585x297.png 585w" sizes="(max-width: 933px) 100vw, 933px" /></a></p>
<h1>Multi-factor authentication</h1>
<p>While the above setup looks good, you still need MFA to make things even more secure. Go to the app settings in Okta and click on the Sign On tab then click Edit.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-32.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-32.png" alt="" width="736" height="256" class="aligncenter size-full wp-image-6535" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-32.png 736w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-32-300x104.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-32-585x203.png 585w" sizes="(max-width: 736px) 100vw, 736px" /></a><br />
Scroll all the way down and click on Add Rule.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-33.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-33.png" alt="" width="741" height="360" class="aligncenter size-full wp-image-6536" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-33.png 741w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-33-300x146.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-33-585x284.png 585w" sizes="(max-width: 741px) 100vw, 741px" /></a><br />
Name the rule however you want and scroll all the way down.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-34.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-34.png" alt="" width="806" height="206" class="aligncenter size-full wp-image-6537" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-34.png 806w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-34-300x77.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-34-768x196.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-34-585x150.png 585w" sizes="(max-width: 806px) 100vw, 806px" /></a><br />
Click on Prompt for fact and choose whatever you want from the settings.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-35.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-35.png" alt="" width="784" height="536" class="aligncenter size-full wp-image-6538" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-35.png 784w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-35-300x205.png 300w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-35-768x525.png 768w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-35-585x400.png 585w" sizes="(max-width: 784px) 100vw, 784px" /></a><br />
Once configured, when you log in to your Okta dashboard, you&#8217;ll get in without prompted for MFA, but when you click on the AWS Console app, you&#8217;ll get redirected to AWS to configure your MFA. You can use the Okta mobile app for MFA or Authy which I prefer. This is because we configured the MFA to occur on the AWS level, not on Okta level.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2020/02/P145-36.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2020/02/P145-36.png" alt="" width="511" height="628" class="aligncenter size-full wp-image-6540" srcset="https://blog.andreev.it/wp-content/uploads/2020/02/P145-36.png 511w, https://blog.andreev.it/wp-content/uploads/2020/02/P145-36-244x300.png 244w" sizes="(max-width: 511px) 100vw, 511px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2020/02/aws-okta-single-sign-on-in-aws-console-using-okta-and-on-prem-active-directory-ad/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CentOS: Setup Samba as an AD Domain Member</title>
		<link>https://blog.andreev.it/2016/09/95-centos-setup-samba-as-an-ad-domain-member/</link>
					<comments>https://blog.andreev.it/2016/09/95-centos-setup-samba-as-an-ad-domain-member/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Tue, 06 Sep 2016 21:33:01 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Samba]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=2720</guid>

					<description><![CDATA[This post is a slight modification of the official wiki for setting up Samba&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>This post is a slight modification of the <a href="https://wiki.samba.org/index.php/Setup_Samba_as_an_AD_Domain_Member" target="_blank" rel="noopener noreferrer">official wiki</a> for setting up Samba as an AD Domain Member. </p>
<p>In my lab, I built a Windows 2012R2 domain controller/DNS and a CentOS 7.1 VM running Samba 4.2.10.<br />
My Windows domain is <strong>kdomain.local</strong> and the NETBIOS name is <strong>MYDOMAIN</strong>. They are on the same subnet and the IP of the CentOS VM is in the DNS. Let&#8217;s verify the prerequisites before we install Samba. Make sure that everything checks out. </p>
<p>Check the hostname first.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
hostname
centos7dd.kdomain.local
</pre>
<p>If you need to change the hostname, use <strong>hostnamectl set-hostname your_hostname</strong><br />
Make sure your resolver points to a valid domain controller. </p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
cat /etc/resolv.conf
search kdomain.local
nameserver 192.168.1.19
</pre>
<p>Check your IP.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
ip addr show | grep inet
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
    inet 192.168.1.6/24 brd 192.168.1.255 scope global eno16777736
</pre>
<p>Check the resolving. <strong>dc03 </strong>is my domain controller, <strong>centos7dd </strong>is my CentOS member server, the one that I am configuring.</p>
<pre class="brush: bash; title: ; notranslate">
host -t A dc03.kdomain.local
dc03.kdomain.local has address 192.168.1.19
host -t A centos7dd.kdomain.local
centos7dd.kdomain.local has address 192.168.1.6
</pre>
<p>If you get an error that host is an unknown command, install bind-utils with <strong>yum install bind-utils</strong>. You don&#8217;t have to, but make sure that all IPs and resolving works fine.<br />
Some more checks, to see if you don&#8217;t have something messed up in <strong>/etc/hosts</strong> file.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
getent hosts centos7dd
192.168.1.6     centos7dd.kdomain.local
</pre>
<p>Now it&#8217;s time to install samba.</p>
<pre class="brush: bash; title: ; notranslate">
yum install samba samba-devel samba-winbind samba-winbind-clients
</pre>
<p>Before you go further, you need to know what&#8217;s realm, NETBIOS and workgroup in Samba terms. They are kind of misleading as you can see below from the samba config file. On the domain controller, open up a command prompt and type:</p>
<pre class="brush: plain; highlight: [1]; title: ; notranslate">
set | find  &quot;DOMAIN&quot;
USERDNSDOMAIN=KDOMAIN.LOCAL
USERDOMAIN=MYDOMAIN
USERDOMAIN_ROAMINGPROFILE=MYDOMAIN
</pre>
<p>My domain is <strong>KDOMAIN.LOCAL</strong> and the NETBIOS domain name is <strong>MYDOMAIN</strong>. The hostname of my domain controller is <strong>DC03</strong>, but that&#8217;s irrelevant.<br />
Find where the config file is stored.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
smbd -b | grep CONFIGFILE
   CONFIGFILE: /etc/samba/smb.conf
</pre>
<p>Rename the original file as something else and edit <strong>smb.conf</strong> so it&#8217;s an empty file. Add the following lines there.</p>
<pre class="brush: bash; title: ; notranslate">
&#x5B;global]
        netbios name = centos7dd
        realm = KDOMAIN.LOCAL
        workgroup = MYDOMAIN
        security = ADS
        winbind enum groups = Yes
        winbind enum users = Yes
        winbind nss info = rfc2307
        idmap config *:range = 2000-9999
        idmap config * : backend = tdb
</pre>
<p>Now, you can join the VM to the domain.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
net ads join -U administrator
Enter administrator's password:
Using short domain name -- MYDOMAIN
Joined 'CENTOS7DD' to dns domain 'kdomain.local'
</pre>
<p>Let&#8217;s make sure that Samba starts now and on each boot.</p>
<pre class="brush: bash; title: ; notranslate">
systemctl start smb.service
systemctl start nmb.service
systemctl start winbind.service
systemctl enable smb.service
systemctl enable nmb.service
systemctl enable winbind.service
</pre>
<p>Make sure you get the domain users and groups back.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
wbinfo -u
MYDOMAIN\administrator
MYDOMAIN\guest
MYDOMAIN\klimenta
MYDOMAIN\krbtgt
</pre>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
wbinfo -g
MYDOMAIN\winrmremotewmiusers__
MYDOMAIN\domain computers
MYDOMAIN\domain controllers
MYDOMAIN\schema admins
MYDOMAIN\enterprise admins
....
</pre>
<p>Now, edit <strong>/etc/nsswitch.conf</strong> and modify these three lines. Just add <strong>winbind </strong>after <strong>sss </strong>for <strong>passwd </strong>, <strong>shadow </strong>and <strong>group </strong>entries, so it looks like this. Don&#8217;t change the lines where it says <strong>#passwd:    db files nisplus nis</strong>.</p>
<pre class="brush: bash; title: ; notranslate">
passwd:     files sss winbind
shadow:     files sss winbind
group:      files sss winbind
</pre>
<p>Now, do <strong>getent passwd</strong> and <strong>getent group</strong>. You should recieve both local and domain users and groups as output.</p>
<p>Finally, if you have a firewall, add an exception for Samba services.</p>
<pre class="brush: bash; title: ; notranslate">
firewall-cmd --permanent --zone=public --add-service=samba
firewall-cmd --reload
</pre>
<p>At this point, you&#8217;ll have the OS fully configured as a domain member, but you still can&#8217;t log in to CentOS with a domain account. In order to do that, we&#8217;ll have to run <strong>authconfig-tui</strong>. NOTE: For CentOS 8 use <code>authselect select winbind --force</code>.</p>
<pre class="brush: bash; title: ; notranslate">
authconfig-tui
</pre>
<p>Make sure these options are set. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2016/09/P074-01.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2016/09/P074-01.png" alt="" width="583" height="390" class="aligncenter size-full wp-image-7562" srcset="https://blog.andreev.it/wp-content/uploads/2016/09/P074-01.png 583w, https://blog.andreev.it/wp-content/uploads/2016/09/P074-01-300x201.png 300w, https://blog.andreev.it/wp-content/uploads/2016/09/P074-01-263x175.png 263w" sizes="(max-width: 583px) 100vw, 583px" /></a><br />
&#8230;and these. You don&#8217;t have to join to the domain, just select OK. </p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2016/09/P074-02.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2016/09/P074-02.png" alt="" width="530" height="357" class="aligncenter size-full wp-image-7563" srcset="https://blog.andreev.it/wp-content/uploads/2016/09/P074-02.png 530w, https://blog.andreev.it/wp-content/uploads/2016/09/P074-02-300x202.png 300w" sizes="(max-width: 530px) 100vw, 530px" /></a><br />
This utility will change a lot of files, especially those in <strong>/etc/pam.d </strong>directory and it will also change <strong>smb.conf</strong>. Restart the winbind service in order for these changes to take effect.</p>
<pre class="brush: bash; title: ; notranslate">
systemctl restart winbind.service
</pre>
<p>Make sure you have these lines in <strong>smb.conf</strong>.</p>
<pre class="brush: bash; title: ; notranslate">
template shell = /bin/sh
template homedir = /home/%D/%U
</pre>
<p>Reload Samba config.</p>
<pre class="brush: bash; title: ; notranslate">
systemctl reload smb.service
</pre>
<p>Because of the <strong>template homedir</strong> directive above, all home directories for the domain users will be under <strong>/home/MYDOMAIN</strong> (or whatever domain you have).<br />
Finally, create the home dir and log as the user.</p>
<pre class="brush: bash; title: ; notranslate">
mkdir -p /home/MYDOMAIN/klimenta
cd /home/MYDOMAIN
chown -R klimenta@kdomain.local klimenta
</pre>
<p>Now, you can log as the domain user.</p>
<pre class="brush: bash; highlight: [1,2]; title: ; notranslate">
login as: klimenta@kdomain.local
klimenta@kdomain.local@192.168.1.6's password:
Last login: Wed Sep  7 11:08:10 2016 from 192.168.1.101
-bash-4.2$ pwd
/home/MYDOMAIN/klimenta
</pre>
<p>What if we want to share our home or some other folder on the CentOS server? We have to add a config change in smb.conf file. I&#8217;ll explain how to share the home folder. If you want to share some other folder, make sure that the domain user has rights to that folder. In my case, I&#8217;ll have the domain user klimenta access the shared home folder for the domain user klimenta on the CentOS server. The permissions are already in place. Edit <strong>/etc/samba/smb.conf</strong> file and add these lines at the end.</p>
<pre class="brush: bash; title: ; notranslate">
&#x5B;share]
        comment = klimenta domain user share
        path =  /home/MYDOMAIN/klimenta
        valid users = klimenta@kdomain.local
        guest ok = no
        writable = yes
        browsable = yes
</pre>
<p>Restart both services</p>
<pre class="brush: bash; title: ; notranslate">
systemctl restart smb.service
systemctl restart nmb.service
</pre>
<p>Now, from a Windows workstation go to \\<centos_ip> and you&#8217;ll see the folder opened with all the files in there.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2016/09/95-centos-setup-samba-as-an-ad-domain-member/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>FreeBSD: Setup Samba as an AD Domain Member</title>
		<link>https://blog.andreev.it/2016/08/93-freebsd-setup-samba-as-an-ad-domain-member/</link>
					<comments>https://blog.andreev.it/2016/08/93-freebsd-setup-samba-as-an-ad-domain-member/#comments</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Sat, 27 Aug 2016 00:40:40 +0000</pubDate>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[Samba]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=2676</guid>

					<description><![CDATA[This post is a slight modification of the official wiki for setting up Samba&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>This post is a slight modification of the <a href="https://wiki.samba.org/index.php/Setup_Samba_as_an_AD_Domain_Member" target="_blank" rel="noopener noreferrer">official wiki</a> for setting up Samba as an AD Domain Member. The wiki mentioned is a great article, but as described it doesn&#8217;t work on FreeBSD. There are two extra changes that you have to make and these changes are described below.</p>
<p>In my lab, I built a Windows 2012R2 domain controller/DNS and a FreeBSD 10.1 VM running Samba 4.4.5.<br />
My Windows domain is <strong>kdomain.local</strong> and the NETBIOS name is <strong>MYDOMAIN</strong>. They are on the same subnet and the IP of the BSD VM is in the DNS. Let&#8217;s verify the prerequisites before we install Samba. Make sure that everything checks out. </p>
<p>This is the full name of my BSD VM.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
hostname
freebsd03.kdomain.local
</pre>
<p>This is what I have in <strong>resolv.conf</strong>. 192.168.1.19 is the IP of the Windows box.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
cat /etc/resolv.conf
search kdomain.local
nameserver 192.168.1.19
</pre>
<p>This is the hostname and the IP of my BSD box.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
cat /etc/rc.conf
hostname=&quot;freebsd03.kdomain.local&quot;
ifconfig_em0=&quot;inet 192.168.1.18 netmask 255.255.255.0&quot;
</pre>
<p>Make sure it resolves properly in DNS.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
host -t A freebsd03.kdomain.local
freebsd03.kdomain.local has address 192.168.1.18
</pre>
<p>Check the date/time on both systems. They have to be the same. If the time is not the same, it&#8217;s fine, but they have to be in different time zones.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
date
Fri Aug 26 19:26:24 EDT 2016
</pre>
<p>Another check using <strong>getent </strong>in case you have something in <strong>/etc/hosts.</strong></p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
getent hosts freebsd03
192.168.1.18      freebsd03.kdomain.local
</pre>
<p>If everything checks out, you can install samba.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
pkg install samba44
</pre>
<p>This is where Samba expects the config file which doesn&#8217;t exist by default.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
smbd -b | grep CONFIGFILE
   CONFIGFILE: /usr/local/etc/smb4.conf
</pre>
<p>The log dir is automatically created under <strong>/var/log/samba4</strong>. If you need to change the log dir or any other input parameters, look at <strong>/usr/local/etc/rc.d/samba_server</strong> file, but don&#8217;t change this file. Use the parameters there to change them in <strong>/etc/rc.conf</strong>. </p>
<p>Before you go further, you need to know what&#8217;s realm, NETBIOS and workgroup in Samba terms. They are kind of misleading as you can see below from the samba config file. On the domain controller, open up a command prompt and type:</p>
<pre class="brush: plain; highlight: [1]; title: ; notranslate">
set | find  &quot;DOMAIN&quot;
USERDNSDOMAIN=KDOMAIN.LOCAL
USERDOMAIN=MYDOMAIN
USERDOMAIN_ROAMINGPROFILE=MYDOMAIN
</pre>
<p>My domain is <strong>KDOMAIN.LOCAL</strong> and the NETBIOS domain name is <strong>MYDOMAIN</strong>. The hostname of my domain controller is <strong>DC03</strong>, but that&#8217;s irrelevant.<br />
Now create the Samba config file which is <strong>/usr/local/etc/smb4.conf</strong>.</p>
<pre class="brush: bash; title: ; notranslate">
&#x5B;global]
        netbios name = freebsd03
        realm = KDOMAIN.LOCAL
        workgroup = MYDOMAIN
        security = ADS
        winbind enum groups = Yes
        winbind enum users = Yes
        winbind nss info = rfc2307
        idmap config *:range = 2000-9999
        idmap config * : backend = tdb
</pre>
<p>As you can see the netbios name is not the netbios name of your domain controller, it&#8217;s the hostname of your BSD box. The realm is the domain name and the workgroup is the NETBIOS name of the domain controller. Yep, it is misleading, but it is what it is.</p>
<p>Previously, I mentioned that there are two changes that you have to make that are different than the original wiki. So, this is the first change. In the original wiki article, they suggest picking up one of the three idmap modules.</p>
<pre class="brush: bash; title: ; notranslate">
   # Just adding the following three lines is not enough!!
       #  - idmap config ad
       #  - idmap config rid
       #  - idmap_config_autorid
</pre>
<p>If you go ahead and implement any of them, you won&#8217;t be able to enumerate the domain users with <strong>getent</strong>. More info <a href="https://forums.freebsd.org/threads/46104/" target="_blank" rel="noopener noreferrer">here</a>. So, skip that and just do the config file as described above.</p>
<p>Now that you have your config in place, check for any errors. Just do <strong>testparm</strong>.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
testparm
Load smb config files from /usr/local/etc/smb4.conf
Loaded services file OK.
Server role: ROLE_DOMAIN_MEMBER

Press enter to see a dump of your service definitions

# Global parameters
&#x5B;global]
        realm = KDOMAIN.LOCAL
        workgroup = MYDOMAIN
        security = ADS
        winbind enum groups = Yes
        winbind enum users = Yes
        winbind nss info = rfc2307
        idmap config *:range = 2000-9999
        idmap config * : backend = tdb
</pre>
<p>If everything is syntax OK, you can now join the BSD box to the domain.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
net ads join -U administrator
Enter administrator's password:
Using short domain name -- MYDOMAIN
Joined 'FREEBSD03' to dns domain 'kdomain.local'
</pre>
<p>If you go back to your domain controller and open the ADUC (Active Directory Users and Computers), you&#8217;ll see your BSD hostname there.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2016/08/P072-01.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2016/08/P072-01.png" alt="" width="528" height="123" class="aligncenter size-full wp-image-7545" srcset="https://blog.andreev.it/wp-content/uploads/2016/08/P072-01.png 528w, https://blog.andreev.it/wp-content/uploads/2016/08/P072-01-300x70.png 300w" sizes="(max-width: 528px) 100vw, 528px" /></a><br />
Add these two lines to <strong>/etc/rc.conf.</strong></p>
<pre class="brush: bash; title: ; notranslate">
samba_server_enable=&quot;YES&quot;
winbindd_enable=&quot;YES&quot;
</pre>
<p>Now, you can start Samba with <strong>service samba_server start</strong>. It also starts <strong>winbind </strong>daemon.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
service samba_server start
Performing sanity check on Samba configuration: OK
Starting nmbd.
Starting smbd.
Starting winbindd.
</pre>
<p>Do all the checks.</p>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
wbinfo -u
MYDOMAIN\administrator
MYDOMAIN\guest
MYDOMAIN\klimenta
MYDOMAIN\krbtgt
</pre>
<pre class="brush: bash; highlight: [1]; title: ; notranslate">
wbinfo -g
MYDOMAIN\winrmremotewmiusers__
MYDOMAIN\domain computers
...
</pre>
<p>Now, do <strong>getent passwd</strong>. You won’t receive any domain users.<br />
This is the second change that doesn&#8217;t apply from the official wiki. You&#8217;ll have to modify <strong>/etc/nsswitch.conf</strong>, so it looks like this. You have to replace <strong>compat </strong>with <strong>files </strong>for <strong>group </strong>and <strong>passwd </strong>entries.</p>
<pre class="brush: bash; title: ; notranslate">
group: files winbind
group_compat: nis
hosts: files dns
networks: files
passwd: files winbind
passwd_compat: nis
</pre>
<p>Reboot, and do <strong>getent passwd</strong> and <strong>getent group</strong> at this point. If you get the domain users and group, you are all set.</p>
<p>If you use pf, make sure that these ports are opened.</p>
<p><a href="https://blog.andreev.it/wp-content/uploads/2016/08/P072-02.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2016/08/P072-02.png" alt="" width="512" height="259" class="aligncenter size-full wp-image-7546" srcset="https://blog.andreev.it/wp-content/uploads/2016/08/P072-02.png 512w, https://blog.andreev.it/wp-content/uploads/2016/08/P072-02-300x152.png 300w" sizes="(max-width: 512px) 100vw, 512px" /></a><br />
At this point, you’ll have the OS fully configured as a domain member, but you still can’t log in to FreeBSD with a domain account. In order to do that, we’ll have to make some changes. </p>
<p>Make sure you have these lines in <strong>smb.conf</strong>, restart samba service if necessary.</p>
<pre class="brush: bash; title: ; notranslate">
template shell = /bin/sh
template homedir = /home/%D/%U
</pre>
<p>The template shell and homedir means that each domain user will use <strong>/bin/sh</strong> for a shell and each home directory is expected to be under /home/ + domain name + the user name, in my case <strong>/home/MYDOMAIN/klimenta</strong>. Next, we should create a home dir for one of the users. In my case:</p>
<pre class="brush: bash; title: ; notranslate">
mkdir -p /home/MYDOMAIN/klimenta
cd /home/MYDOMAIN
chown -R klimenta@kdomain.local klimenta
</pre>
<p>Finally, the following three files needs to be modified: <strong>/etc/pam.d/sshd</strong>, <strong>/etc/pam.d/system</strong> and <strong>/etc/ssh/sshd_config</strong>. Reboot after the modifications. </p>
<p>In <strong>/etc/ssh/sshd_config</strong>, make sure these two lines are uncommented and set to yes and no. </p>
<pre class="brush: bash; title: ; notranslate">
PasswordAuthentication yes
ChallengeResponseAuthentication no
</pre>
<p>In <strong>/etc/pam.d/sshd</strong>, make sure you add this line three times so it looks like this. The order is also important. </p>
<pre class="brush: bash; highlight: [4,10,21]; title: ; notranslate">
# auth
auth            sufficient      pam_opie.so             no_warn no_fake_prompts
auth            requisite       pam_opieaccess.so       no_warn allow_local
auth            sufficient      /usr/local/lib/pam_winbind.so
#auth           sufficient      pam_krb5.so             no_warn try_first_pass
#auth           sufficient      pam_ssh.so              no_warn try_first_pass
auth            required        pam_unix.so             no_warn try_first_pass

# account
account         sufficient      /usr/local/lib/pam_winbind.so
account         required        pam_nologin.so
#account        required        pam_krb5.so
account         required        pam_login_access.so
account         required        pam_unix.so

# session
#session        optional        pam_ssh.so              want_agent
session         required        pam_permit.so

# password
password        sufficient      /usr/local/lib/pam_winbind.so
#password       sufficient      pam_krb5.so             no_warn try_first_pass
password        required        pam_unix.so             no_warn try_first_pass
</pre>
<p>In <strong>/etc/pam.d/system</strong>, make sure you add this line three times so it looks like this. The order is also important. </p>
<pre class="brush: bash; highlight: [4,10,20]; title: ; notranslate">
# auth
auth            sufficient      pam_opie.so             no_warn no_fake_prompts
auth            requisite       pam_opieaccess.so       no_warn allow_local
auth            sufficient      /usr/local/lib/pam_winbind.so
#auth           sufficient      pam_krb5.so             no_warn try_first_pass
#auth           sufficient      pam_ssh.so              no_warn try_first_pass
auth            required        pam_unix.so             no_warn try_first_pass nullok

# account
account         sufficient      /usr/local/lib/pam_winbind.so
#account        required        pam_krb5.so
account         required        pam_login_access.so
account         required        pam_unix.so

# session
#session        optional        pam_ssh.so              want_agent
session         required        pam_lastlog.so          no_fail

# password
password        sufficient      /usr/local/lib/pam_winbind.so
#password       sufficient      pam_krb5.so             no_warn try_first_pass
password        required        pam_unix.so             no_warn try_first_pass
</pre>
<p>At this point, after the reboot of course, you can log as a domain member.<br />
What if we want to share our home directory or some other directory on the FreeBSD server? We have to add a config change in smb.conf file. I&#8217;ll explain how to share the home directory. If you want to share some other directory, make sure that the domain user has rights to that directory. In my case, I&#8217;ll have the domain user klimenta access the shared home directory for the domain user klimenta on the FreeBSD server. The permissions are already in place. Edit <strong>/usr/local/etc/smb4.conf</strong> file and add these lines at the end.</p>
<pre class="brush: bash; title: ; notranslate">
&#x5B;share]
        comment = klimenta domain user share
        path =  /home/MYDOMAIN/klimenta
        valid users = klimenta@kdomain.local
        guest ok = no
        writable = yes
        browsable = yes
</pre>
<p>Restart samba service.</p>
<pre class="brush: bash; title: ; notranslate">
service samba_server start
</pre>
<p>Now, from a Windows workstation go to \\freebsd03 and you&#8217;ll see the directory.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2016/08/93-freebsd-setup-samba-as-an-ad-domain-member/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
