
{"id":3714,"date":"2022-05-16T22:27:42","date_gmt":"2022-05-16T22:27:42","guid":{"rendered":"https:\/\/blog.gordonbuchan.com\/blog\/?p=3714"},"modified":"2023-11-10T16:22:53","modified_gmt":"2023-11-10T16:22:53","slug":"integrating-open-source-software-in-the-enterprise-chapter-1-creating-a-network-file-share-with-linux-and-samba-authenticating-against-active-directory","status":"publish","type":"post","link":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/2022\/05\/16\/integrating-open-source-software-in-the-enterprise-chapter-1-creating-a-network-file-share-with-linux-and-samba-authenticating-against-active-directory\/","title":{"rendered":"Creating a network file share with Linux and Samba authenticating against Active Directory"},"content":{"rendered":"\n<p>In this procedure we create a network file share by integrating the open source program Samba running on Linux with Active Directory to authenticate access to the network file share.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Business case<\/h1>\n\n\n\n<p>A computer running Linux and Samba can create a network file share authenticating against a company&#8217;s Active Directory. This means that a Linux server and Samba network file share software can replace a Windows server for the network file share role in the enterprise, reducing software licensing costs and improving security and stability.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">This procedure was tested on Ubuntu Linux 22.04 LTS<\/h1>\n\n\n\n<p>This procedure was tested on <a href=\"https:\/\/releases.ubuntu.com\/22.04\/\">Ubuntu Linux 22.04 LTS<\/a><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Understanding the test network<\/h1>\n\n\n\n<p>This procedure was tested on a network of 3 virtual machines, each running in bridge mode, on different hypervisor hosts.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"786\" src=\"https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image.png\" alt=\"\" class=\"wp-image-3804\" srcset=\"https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image.png 927w, https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-300x254.png 300w, https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-768x651.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>sudbury<\/td><td>Windows Server 2019 acting as Active Directory controller for the clarkcounty.gordonbuchan.com domain.<\/td><\/tr><tr><td>sandiego<\/td><td>Ubuntu Linux 22.04LTS desktop joined to the clarkcounty.gordonbuchan.com domain, authenticating access to a network file share enabled by Samba and Winbind against the Active Directory controller for the domain clarkcounty.gordonbuchan.com on sudbury.<\/td><\/tr><tr><td>hamilton<\/td><td>Windows 10 Pro workstation joined to the clarkcounty.gordonbuchan.com domain.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Understanding Active Directory<\/h1>\n\n\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Active_Directory\">Active Directory<\/a> is commercial software developed by Microsoft that  runs primarily on Windows Server. Active Directory can authenticate users and groups of users, and can control access to resources like network file shares and &#8220;Single Sign-On&#8221; (SSO) login to computers connected to the network.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Understanding Samba<\/h1>\n\n\n\n<p><a href=\"https:\/\/www.samba.org\/\">Samba<\/a> is open source free software that enables a Linux server to provide a network file share that can be accessed by Windows computers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A note re Samba&#8217;s included Active Directory functionality<\/h2>\n\n\n\n<p>Samba itself is able to act as an Active Directory controller and can implement a subset of Active Directory&#8217;s features. This post assumes that you are authenticating against an Active Directory controller running on Windows Server.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Understanding Winbind<\/h1>\n\n\n\n<p><a href=\"https:\/\/www.samba.org\/samba\/docs\/current\/man-html\/winbindd.8.html\">Winbind<\/a> is software that enables Samba to integrate with Active Directory to authenticate access to a network file share.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Understanding System Security Services Daemon (SSSD)<\/h1>\n\n\n\n<p><a href=\"https:\/\/sssd.io\/\">SSSD<\/a> is a technology that enables Active Directory integration for Linux workstations. In practice, it is difficult to integrate SSSD with Samba for Active Directory authentication in a stable fashion. There are some approaches to SSSD which incorporate Winbind for a hybrid approach. This procedure will focus on using Winbind, and without using SSSD.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Choosing Winbind over SSSD for a network file share authenticaticated against Active Directory<\/h1>\n\n\n\n<p>This procedure will use Winbind to enable Samba to integrate with Active Directory to create a network file share authenticated against Active Directory.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Objectives<\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Access to the network file share authenticated against Active Directory.<\/li>\n\n\n\n<li>The network file share must be accessible to workstations with &#8220;Enable insecure guest logins&#8221; set to &#8220;Disabled.&#8221;<\/li>\n\n\n\n<li>The network file share must observe ACL and allow overrides by Windows clients for ownership and permissions.<\/li>\n<\/ul>\n\n\n\n<p>(Single-Sign-On (SSO) and SSSD will be addressed in a later procedure.)<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Creating the Active Directory group example_group and adding members to the group<\/h1>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"578\" height=\"492\" src=\"https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-1.png\" alt=\"\" class=\"wp-image-3857\" srcset=\"https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-1.png 578w, https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-1-300x255.png 300w\" sizes=\"auto, (max-width: 578px) 100vw, 578px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Entering commands as root<\/h1>\n\n\n\n<p>This procedure assumes that you are logged in as the root user of the Linux server.<\/p>\n\n\n\n<p>Escalate to the root user:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo su\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Replacing the example realm\/domain name with your realm\/domain name<\/h1>\n\n\n\n<p>Please replace the sample realm\/domain name clarkcounty.gordonbuchan.com with your realm\/domain name.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Setting the system hostname<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nhostnamectl set-hostname sandiego.clarkcounty.gordonbuchan.com\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Configuring the \/etc\/hosts file<\/h1>\n\n\n\n<p>Associate the host name of your Linux server with its IP address:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd \/etc\nnano hosts\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n192.168.33.110   sandiego\n192.168.33.110   sandiego.clarkcounty.gordonbuchan.com\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Setting DNS<\/h1>\n\n\n\n<p>Disable systemd-resolved service:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsystemctl stop systemd-resolved\nsystemctl disable systemd-resolved\n<\/pre><\/div>\n\n\n<p>Unlink the symbolic link \/etc\/resolv.conf:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd \/etc\nunlink resolv.conf\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Creating a new \/etc\/resolv.conf file<\/h2>\n\n\n\n<p>Ensure that the first nameserver entry is the IP address of the Active Directory server.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnano resolv.conf\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnameserver 192.168.33.80\nnameserver 8.8.8.8\nsearch clarkcounty.gordonbuchan.com\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nreboot\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Installing software<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\napt install acl samba winbind libnss-winbind krb5-user\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Note: for the files \/etc\/krb5.conf and \/etc\/samba\/smb.conf, the realm\/domain name must be in UPPERCASE letters<\/h1>\n\n\n\n<p>The realm\/domain name must be in UPPERCASE letters. This includes the long version CLARKCOUNTY.GORDONBUCHAN.COM and short version CLARKCOUNTY of the realm\/domain name.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Configuring Kerberos<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd \/etc\ncp krb5.conf krb5.conf.orig\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnano krb5.conf\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;libdefaults]\ndefault_realm = CLARKCOUNTY.GORDONBUCHAN.COM\ndns_lookup_realm = false\ndns_lookup_kdc = true\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Configuring Nsswitch<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd \/etc\ncp nsswitch.conf nsswitch.conf.orig\nnano nsswitch.conf\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npasswd: files winbind\ngroup: files winbind\nhosts: files dns wins\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nchmod 550 nsswitch.conf\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Configuring Samba (1\/2)<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd \/etc\/samba\ncp smb.conf smb.conf.orig\nnano smb.conf\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;global]\n   realm = CLARKCOUNTY.GORDONBUCHAN.COM\n   security = ADS\n   workgroup = CLARKCOUNTY\n\n   idmap config SAMDOM : range = 10000 - 999999\n   idmap config SAMDOM : backend = rid\n   idmap config * : range = 3000-7999\n   idmap config * : backend = tdb\n\n   map acl inherit = Yes\n   vfs objects = acl_xattr\n\n   dedicated keytab file = \/etc\/krb5.keytab\n   kerberos method = secrets and keytab\n   winbind refresh tickets = Yes\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Obtaining a Kerberos ticket<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nkinit admingordon\nklist\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Joining the Active Directory domain<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnet ads info testjoin\nnet ads -v join -U admingordon\nnet ads info\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Restarting services (1\/2)<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsystemctl restart smbd nmbd winbind\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Creating the share folder<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd \/home\nmkdir example_share\nchmod -R 2770 example_share\nchown -R &quot;CLARKCOUNTY\\admingordon&quot;:&quot;CLARKCOUNTY\\example_group&quot; example_share\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Configuring Samba (2\/2)<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd \/etc\/samba\ncp smb.conf smb.conf.orig\nnano smb.conf\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n   &#x5B;Share]\n   acl_xattr:ignore system acl = Yes\n   acl allow execute always = Yes\n   acl group control = Yes\n   inherit acls = Yes\n   inherit owner = windows and unix\n   inherit permissions = Yes\n   path = \/media\/share\n   read only = No\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Restarting services (2\/2)<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsystemctl restart smbd nmbd winbind\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Mapping sid==5-1-5-32-546 to nogroup<\/h1>\n\n\n\n<p>This SID must be mapped to the UNIX group nogroup:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnet groupmap add sid=S-1-5-32-546 unixgroup=nogroup type=builtin\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\">Connecting to the network file share from a Windows computer joined to the domain<\/h1>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"809\" height=\"582\" src=\"https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-2.png\" alt=\"\" class=\"wp-image-3859\" srcset=\"https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-2.png 809w, https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-2-300x216.png 300w, https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-2-768x553.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Applying Windows Access Control Lists (ACLs) from a Windows computer joined to the domain<\/h1>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"441\" src=\"https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-4.png\" alt=\"\" class=\"wp-image-3872\" srcset=\"https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-4.png 768w, https:\/\/blog.gordonbuchan.com\/blog\/wp-content\/uploads\/2022\/05\/image-4-300x172.png 300w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">References<\/h1>\n\n\n\n<p><a href=\"http:\/\/blog.jrg.com.br\/2021\/02\/01\/ubuntu-focal-fossa-samba-domain-member-shares-1\/\">http:\/\/blog.jrg.com.br\/2021\/02\/01\/ubuntu-focal-fossa-samba-domain-member-shares-1\/<\/a><a href=\"http:\/\/koo.fi\/blog\/2015\/06\/16\/ubuntu-14-04-active-directory-authentication\/\n\"><br><\/a><a href=\"https:\/\/docs.vmware.com\/en\/VMware-Horizon-7\/7.13\/linux-desktops-setup\/GUID-F8F0CFCF-C4D6-4784-85FF-E7C6DF575F49.html\">https:\/\/docs.vmware.com\/en\/VMware-Horizon-7\/7.13\/linux-desktops-setup\/GUID-F8F0CFCF-C4D6-4784-85FF-E7C6DF575F49.html<\/a><br><a href=\"https:\/\/ubuntu.com\/server\/docs\/service-sssd-ad\">https:\/\/ubuntu.com\/server\/docs\/service-sssd-ad<\/a><br><a href=\"https:\/\/wiki.samba.org\/index.php\/Setting_up_Samba_as_a_Domain_Member\n\">https:\/\/wiki.samba.org\/index.php\/Setting_up_Samba_as_a_Domain_Member<\/a><a href=\"https:\/\/www.google.com\/search?q=kinit%3A+KDC+reply+did+not+match+expectations+while+getting+initial+credentials&amp;oq=kinit%3A+KDC+reply+did+not+match+expectations+while+getting+initial+credentials&amp;aqs=chrome..69i57j69i58.814j0j7&amp;sourceid=chrome&amp;ie=UTF-8\n\"><br><\/a><a href=\"https:\/\/www.jurisic.org\/post\/2021\/11\/24\/SAMBA-Domain-Member-as-File-Server\n\">https:\/\/www.jurisic.org\/post\/2021\/11\/24\/SAMBA-Domain-Member-as-File-Server<\/a><a href=\"https:\/\/www.linuxquestions.org\/questions\/linux-networking-3\/kerberos-kinit-reply-did-not-match-expectations-445698\/\n\"><br><\/a><a href=\"https:\/\/www.moderndeployment.com\/windows-server-2019-active-directory-installation-beginners-guide\/\n\">https:\/\/www.moderndeployment.com\/windows-server-2019-active-directory-installation-beginners-guide\/<br><\/a><a href=\"https:\/\/www.reddit.com\/r\/Ubuntu\/comments\/h01i2w\/cheat_sheet_on_how_to_configure_a_smb_file_server\/\n\">https:\/\/www.reddit.com\/r\/Ubuntu\/comments\/h01i2w\/cheat_sheet_on_how_to_configure_a_smb_file_server\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this procedure we create a network file share by integrating the open source program Samba running on Linux with Active Directory to authenticate access to the network file share. Business case A computer running Linux and Samba can create a network file share authenticating against a company&#8217;s Active Directory. This means that a Linux &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/2022\/05\/16\/integrating-open-source-software-in-the-enterprise-chapter-1-creating-a-network-file-share-with-linux-and-samba-authenticating-against-active-directory\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Creating a network file share with Linux and Samba authenticating against Active Directory&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3714","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=3714"}],"version-history":[{"count":165,"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3714\/revisions"}],"predecessor-version":[{"id":4966,"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3714\/revisions\/4966"}],"wp:attachment":[{"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=3714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=3714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gordonbuchan.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=3714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}