{"id":15804,"date":"2024-05-24T06:36:26","date_gmt":"2024-05-24T06:36:26","guid":{"rendered":"https:\/\/www.insentragroup.com\/us\/insights\/uncategorized\/joining-red-hat-systems-directly-to-multiple-active-directories-using-sssd\/"},"modified":"2024-12-13T02:00:04","modified_gmt":"2024-12-13T02:00:04","slug":"joining-red-hat-systems-directly-to-multiple-active-directories-using-sssd","status":"publish","type":"post","link":"https:\/\/www.insentragroup.com\/us\/insights\/geek-speak\/modern-workplace\/joining-red-hat-systems-directly-to-multiple-active-directories-using-sssd\/","title":{"rendered":"Joining Red Hat Systems Directly to Multiple Active Directories using SSSD"},"content":{"rendered":"\n<p>Did you know you can centrally manage Linux systems and user accounts under an Active Directory domain?\u202f&nbsp;<\/p>\n\n\n\n<p>For many businesses, Active Directory (AD) is the preferred (if not only) directory service.\u202f&nbsp;<\/p>\n\n\n\n<p>If you and your team are in charge of a Linux and Windows hybrid environment, centralizing authentication for both systems makes sense.\u202f\u00a0<\/p>\n\n\n\n<p>In this article, I\u2019ll discuss how to include Linux devices in an Active Directory domain.&nbsp;<\/p>\n\n\n\n<p>For many years, <a href=\"https:\/\/www.insentragroup.com\/us\/insights\/geek-speak\/migrations\/removing-active-directory-heres-what-to-consider-first\/\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Active Directory<\/a>, also referred to as AD, has dominated the market for enterprise access control. It is used by organizations and people all over the world to centrally manage access to organizational resources. You can control who has access to what by managing users, passwords, and resources like computers. Some of you who are reading this article, especially those who work for large organizations, have already dealt with AD. Typically, the interaction involves logging in to all workstations inside the organization using a single set of login credentials.\u202f<\/p>\n\n\n\n<p>Each user in Active Directory is uniquely created as an object with a single set of credentials in a central database. Additionally, every computer system is created as an object. With the same set of credentials, every user has automatic access to every workstation. Any necessary account updates are made once at the centralized database. The same set of credentials can be used by staff members to access the printers. To do that, AD can be connected with the printers\u2019 authentication system.\u202f<\/p>\n\n\n\n<p>It is possible to customize and maintain access to different resources using groups and organizational units. This directory can be expanded to include more information in addition to the phone numbers and email addresses of the personnel.\u202f\u00a0<\/p>\n\n\n\n<p>AD is a kind of distributed database, which is accessed using Lightweight Directory Access Protocol (LDAP).\u202f&nbsp;<\/p>\n\n\n\n<p>What happens, though, if your organization leverages AD and you have a few Red Hat systems but do not want to keep track of a distinct set of login credentials for your Linux users? As it turns out \u2013 you can join the Red Hat systems to AD using sssd.\u202f\u00a0<\/p>\n\n\n\n<p>The System Security Services Daemon (SSSD) is a system service facilitating access to remote directories and authentication mechanisms.\u202f&nbsp;<\/p>\n\n\n\n<p>An SSSD client, on a local system, can be connected to an identity provider.\u202f&nbsp;<\/p>\n\n\n\n<p>For instance:\u202f&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>LDAP directories\u202f&nbsp;<\/li>\n\n\n\n<li>Identity Management (IdM) domain\u202f&nbsp;<\/li>\n\n\n\n<li>Active Directory (AD)\u202f&nbsp;<\/li>\n\n\n\n<li>Kerberos Realm&nbsp;<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An account in multiple AD Directories with privileges necessary to join a system to the domain&nbsp;<\/li>\n\n\n\n<li>A Linux server (Red Hat 8 is used in this example)&nbsp;<\/li>\n\n\n\n<li>Three Domain Controllers<\/li>\n\n\n\n<li>DNS configuration<\/li>\n<\/ul>\n\n\n\n<p>In this example we will use the following:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AD Domains:\n<ul class=\"wp-block-list\">\n<li>example01.net&nbsp;<\/li>\n\n\n\n<li>example02.net&nbsp;<\/li>\n\n\n\n<li>example03.net&nbsp;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>User account to join the domain:\n<ul class=\"wp-block-list\">\n<li>example_admin<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Package Installation<\/h2>\n\n\n\n<p>The following packages need to be installed:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># dnf install sssd realmd oddjob oddjob-mkhomedir adcli krb5-workstation samba-common-tools <\/code><\/pre>\n\n\n\n<p>To ensure that the server can correctly communicate with Active Directory, use the following command:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># update-crypto-policies --set DEFAULT:AD-SUPPORT <\/code><\/pre>\n\n\n\n<p>Ensure that you can resolve the AD domain controllers using dig:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@utility ~]# dig srv _kerberos-master._udp.example01.net \n<br>\n<br>\n; &lt;&lt;&gt;&gt; DiG 9.11.36-RedHat-9.11.36-3.el8_6.1 &lt;&lt;&gt;&gt; srv _kerberos-master._udp.example01.net \n<br>\n;; global options: +cmd \n<br>\n;; Got answer: \n<br>\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NXDOMAIN, id: 9762 \n<br>\n;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 \n<br>\n<br>\n;; OPT PSEUDOSECTION: \n<br>\n; EDNS: version: 0, flags:; udp: 4000 \n<br>\n;; QUESTION SECTION: \n<br>\n;_kerberos-master._udp.example01.net. IN\tSRV \n<br>\n <br>\n<br>\n;; AUTHORITY SECTION: \n<br>\nexample01.net.\t3600\tIN\tSOA\tlmigadc01.example01.net. hostmaster.example01.net. 7082 900 600 86400 3600 \n<br>\n<br>\n;; Query time: 1 msec \n<br>\n;; SERVER: 172.16.34.10#53(172.16.34.10) \n<br>\n;; WHEN: Wed Dec 14 13:49:17 AEDT 2022 \n<br>\n;; MSG SIZE  rcvd: 150 \n<br>\n------------------------------------------ \n<br>\n&#91;root@utility ~]# dig srv _kerberos-master._udp.example02.net \n<br>\n<br>\n; &lt;&lt;&gt;&gt; DiG 9.11.36-RedHat-9.11.36-3.el8_6.1 &lt;&lt;&gt;&gt; srv _kerberos-master._udp.example02.net \n<br>\n;; global options: +cmd \n<br>\n;; Got answer: \n<br>\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NXDOMAIN, id: 9762 \n<br>\n;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 \n<br>\n<br>\n;; OPT PSEUDOSECTION: \n<br>\n; EDNS: version: 0, flags:; udp: 4000 \n<br>\n;; QUESTION SECTION: \n<br>\n;_kerberos-master._udp.example02.net. IN\tSRV \n<br>\n<br>\n;; AUTHORITY SECTION: \n<br>\nexample02.net.\t3600\tIN\tSOA\tlmigadc01.example02.net. hostmaster.example02.net. 7082 900 600 86400 3600 \n <br>\n<br>\n;; Query time: 1 msec \n<br>\n;; SERVER: 172.16.34.10#53(172.16.34.10) \n<br>\n;; WHEN: Wed Dec 14 13:49:17 AEDT 2022 \n<br>\n;; MSG SIZE  rcvd: 150 \n<br>\n<br>\n<br>\n--------------- \n <br>\n<br>\n&#91;root@utility ~]# dig srv _kerberos-master._udp.example03.net \n <br>\n<br>\n; &lt;&lt;&gt;&gt; DiG 9.11.36-RedHat-9.11.36-3.el8_6.1 &lt;&lt;&gt;&gt; srv _kerberos-master._udp.example03.net \n<br>\n;; global options: +cmd \n<br>\n;; Got answer: \n<br>\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NXDOMAIN, id: 9762 \n<br>\n;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 \n<br>\n<br>\n<br>\n;; OPT PSEUDOSECTION: \n<br>\n; EDNS: version: 0, flags:; udp: 4000 \n<br>\n;; QUESTION SECTION: \n<br>\n;_kerberos-master._udp.example03.net. IN\tSRV \n<br>\n <br>\n;; AUTHORITY SECTION: \n<br>\nexample03.net.\t3600\tIN\tSOA\tlmigadc01.example03.net. hostmaster.example03.net. 7082 900 600 86400 3600 \n<br>\n<br>\n;; Query time: 1 msec \n<br>\n;; SERVER: 172.16.34.10#53(172.16.34.10) \n<br>\n;; WHEN: Wed Dec 14 13:49:17 AEDT 2022 \n<br>\n;; MSG SIZE  rcvd: 150 <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Join the first domain from the first forest.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># realm join EXAMPLE01.NET <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add a second domain from a different forest to the <em>[domain_realm] <\/em>section of \/etc\/krb5.conf&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>domain_realm] \n<br>\n .example01.net = EXAMPLE01.NET \n<br>\n example01.net = EXAMPLE01.NET \n<br>\n .example02.net = EXAMPLE02.NET \n<br>\n example02.net = EXAMPLE02.NET \n<br>\n .example03.net = EXAMPLE03.NET \n<br>\n example03.net = EXAMPLE03.NET <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Join the second domain using adcli command.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># adcli join -\u2013host-keytab=\/etc\/krb5.keytab.example02.net example02.net<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Define the second domain section which was joined using adcli into a new domain section in \/etc\/sssd\/sssd.conf configuration file.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;sssd] \n<br>\ndomains = example01.net,example02.net \n<br>\nconfig_file_version = 2 \n<br>\nservices = nss, pam, pac, ssh \n<br>\n <br>\n<br>\n&#91;domain\/example01.net] \n<br>\nad_domain = example01.net \n<br>\nad_server = lmigadc01.example01.net \n<br>\nkrb5_realm = example01.net \n<br>\nrealmd_tags = manages-system joined-with-adcli \n<br>\ncache_credentials = True \n<br>\nid_provider = ad \n<br>\nkrb5_store_password_if_offline = True \n<br>\ndefault_shell = \/bin\/bash \n<br>\nldap_id_mapping = True \n<br>\nuse_fully_qualified_names = True \n<br>\nfallback_homedir = \/home\/%u@%d \n<br>\naccess_provider = ad \n<br>\ndyndns_update = true \n<br>\n <br>\n<br>\n&#91;domain\/example02.net] \n<br>\nad_domain = example02.net \n<br>\nad_server = lcolad01.example02.net \n<br>\nkrb5_realm = example02.net \n<br>\nrealmd_tags = manages-system joined-with-adcli \n<br>\ncache_credentials = True \n<br>\nid_provider = ad \n<br>\nkrb5_store_password_if_offline = True \n<br>\ndefault_shell = \/bin\/bash \n<br>\nldap_id_mapping = True \n<br>\nuse_fully_qualified_names = True \n<br>\nfallback_homedir = \/home\/%u@%d \n<br>\naccess_provider = ad \n<br>\nkrb5_keytab = \/etc\/krb5.keytab.example02.net \n<br>\nldap_krb5_keytab = \/etc\/krb5.keytab.example02.net \n<br>\ndyndns_update = true <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Restart sssd using the following command&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># systemctl restart sssd <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Join the third domain using adcli command&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># adcli join -\u2013host-keytab=\/etc\/krb5.keytab.example03.net example03.net<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Define the third domain section which was joined using adcli into a new domain section in \/etc\/sssd\/sssd.conf configuration file. The following configuration file presents all three domains.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;sssd] \n<br>\ndomains = example01.net,example02.net,example03.net \n<br>\nconfig_file_version = 2 \n<br>\nservices = nss, pam, pac, ssh \n<br>\n <br>\n<br>\n&#91;domain\/example01.net] \n<br>\nad_domain = example01.net \n<br>\nad_server = lmigadc01.example01.net \n<br>\nkrb5_realm = example01.net \n<br>\nrealmd_tags = manages-system joined-with-adcli \n<br>\ncache_credentials = True \n<br>\nid_provider = ad \n<br>\nkrb5_store_password_if_offline = True \n<br>\ndefault_shell = \/bin\/bash \n<br>\nldap_id_mapping = True \n<br>\nuse_fully_qualified_names = True \n<br>\nfallback_homedir = \/home\/%u@%d \n<br>\naccess_provider = ad \n<br>\ndyndns_update = true \n<br>\n <br>\n<br>\n&#91;domain\/example02.net] \n<br>\nad_domain = example02.net \n<br>\nad_server = lcolad01.example02.net \n<br>\nkrb5_realm = example02.net \n<br>\nrealmd_tags = manages-system joined-with-adcli \n<br>\ncache_credentials = True \n<br>\nid_provider = ad \n<br>\nkrb5_store_password_if_offline = True \n<br>\ndefault_shell = \/bin\/bash \n<br>\nldap_id_mapping = True \n<br>\nuse_fully_qualified_names = True \n<br>\nfallback_homedir = \/home\/%u@%d \n<br>\naccess_provider = ad \n<br>\nkrb5_keytab = \/etc\/krb5.keytab.example02.net \n<br>\nldap_krb5_keytab = \/etc\/krb5.keytab.example02.net \n<br>\ndyndns_update = true \n<br>\n <br>\n<br>\n&#91;domain\/example03.net] \n<br>\nad_domain = example03.net \n<br>\nad_server = lavailad02.example03.net \n<br>\nkrb5_realm = example03.net \n<br>\nrealmd_tags = manages-system joined-with-adcli \n<br>\ncache_credentials = True \n<br>\nid_provider = ad \n<br>\nkrb5_store_password_if_offline = True \n<br>\ndefault_shell = \/bin\/bash \n<br>\nldap_id_mapping = True \n<br>\nuse_fully_qualified_names = True \n<br>\nfallback_homedir = \/home\/%u@%d \n<br>\naccess_provider = ad \n<br>\nkrb5_keytab = \/etc\/krb5.keytab.example03.net \n<br>\nldap_krb5_keytab = \/etc\/krb5.keytab.example03.net \n<br>\ndyndns_update = true <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Restart sssd using the following command.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># systemctl restart sssd <\/code><\/pre>\n\n\n\n<p>Note: the ad_server option defines the Domain Controller for the given domain. This option is useful to avoid DNS SRV record lookups and if the Linux server can only resolve DNS names from one of the forest domains. If this is your case \u2013 add the Domain Controllers\u2019 names to \/etc\/hosts as well.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>172.16.32.10 lcolad01.example02.net lcolad01 \n<br>\n172.16.34.10 lmigadc01.example01.net lmigadc01 \n<br>\n172.16.36.10 lavailad02.example03.net lavailad02 <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Testing<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For each domain, execute the following commands.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># id example_admin@example01.net \n<br>\n&#91;root@utility ~]# id example_admin@example01.net \n<br>\nuid=794602228(example_admin@example01.net) gid=794400513(domain users@example01.net) groups=794600513(domain users@example01.net),794600512(domain admins@example01.net) \n<br>\n <br>\n<br>\n# id example_admin@example03.net \n<br>\n&#91;root@utility ~]# id example_admin@example03.net \n<br>\nuid=44201110(example_admin@example03.net) gid=44201177(linux_admins@example03.net) groups=44201177(linux_admins@example03.net),44200513(domain users@example03.net),44201605(idm@example03.net) \n<br>\n <br>\n<br>\n# id example_admin@example02.net \n<br>\n&#91;root@utility ~]# id example_admin@example02.net \n<br>\nuid=81601158(example_admin@example02.net) gid=81600513(domain users@example02.net) groups=81600513(domain users@example02.net),81600512(domain admins@example02.net) <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Attempt to login to the server using ssh.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>root@test ~]# ssh example_admin@example03.net@utility \n<br>\nexample_admin@example03.net@utility's password: \n<br>\nLast login: Wed Dec 14 10:44:59 2022 from 10.221.8.5 \n<br>\n&#91;example_admin@example03.net@utility ~]$ <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Attempt to login to the server using ssh and verify if the KDC grants the Kerberos ticket.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@test ~]# ssh example_admin@example01.net@utility \n<br>\nexample_admin@example01.net@utility's password: \n<br>\nLast login: Wed Dec 14 10:44:23 2022 from 10.221.8.5 \n<br>\n&#91;example_admin@example01.net@utility ~]$ kinit \n<br>\nPassword for example_admin@EXAMPLE01.NET: \n<br>\n&#91;example_admin@example01.net@utility ~]$ klist \n<br>\nTicket cache: KCM:794602128:6396 \n<br>\nDefault principal: example_admin@EXAMPLE01.NET \n<br>\n <br>\n<br>\nValid starting     Expires            Service principal \n<br>\n14\/12\/22 14:19:24  15\/12\/22 00:19:24  krbtgt\/EXAMPLE01.NET@EXAMPLE01.NET <\/code><\/pre>\n\n\n\n<p>Learn how to simplify the way your team manages both Linux and Windows systems, centrally manage your Linux systems and user accounts,\u202f<a href=\"https:\/\/www.insentragroup.com\/nz\/contact\/\" target=\"_blank\" rel=\"noreferrer noopener\">contact us<\/a>\u202fto learn more.&nbsp;<\/p>\n\n\n\n<style>\nbody .wp-block-code>code {\n    font-family: Menlo,Consolas,monaco,monospace;\n    color: #000;\n    padding: 30px 40px;\n    border: none;\n    border-radius: 4px;\n    background: #ddd;\n}\n<\/style>\n","protected":false},"excerpt":{"rendered":"<p>If you and your team are in charge of a Linux and Windows hybrid environment, centralising authentication for both systems makes sense.<\/p>\n","protected":false},"author":67,"featured_media":15805,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[19],"tags":[],"class_list":["post-15804","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-modern-workplace","entry"],"_links":{"self":[{"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/posts\/15804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/users\/67"}],"replies":[{"embeddable":true,"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/comments?post=15804"}],"version-history":[{"count":2,"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/posts\/15804\/revisions"}],"predecessor-version":[{"id":20863,"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/posts\/15804\/revisions\/20863"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/media\/15805"}],"wp:attachment":[{"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/media?parent=15804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/categories?post=15804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.insentragroup.com\/us\/wp-json\/wp\/v2\/tags?post=15804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}