In most enterprises, Microsoft's Active Directory (AD) is the default authentication system for Windows systems and for external, LDAP-connected services. It allows you to configure users and groups, access control, permissions, auto-mounting, and more.
Now, while connecting Linux to an AD cluster cannot support all of the features mentioned, it can handle users, groups, and access control. It is possible (through some configuration tweaks on the Linux side and some advanced options on the AD side) to distribute SSH keys using AD.
This guide, however, will just cover configuring authentication against Active Directory, and will not include any extra configuration on the Windows side.
The domain name ad.company.local throughout this guide will represent the Active Directory domain. To follow this guide, replace it with your AD domain's actual domain name.
The first step to joining a Linux system into AD is to discover your AD cluster, to ensure the network configuration is correct on both sides.
Ensure the following ports are open to your Linux host on your domain controller:
Service
Port(s)
Notes
DNS
53 (TCP+UDP)
Kerberos
88, 464 (TCP+UDP)
Used by kadmin for setting & updating passwords
LDAP
389 (TCP+UDP)
LDAP-GC
3268 (TCP)
LDAP Global Catalog - allows you to source user IDs from AD
Ensure you have configured your AD domain controller as a DNS server on your Rocky Linux host:
With NetworkManager:
# where your primary NetworkManager connection is 'System eth0' and your AD# server is accessible on the IP address 10.0.0.2.[root@host~]$nmcliconmod'System eth0'ipv4.dns10.0.0.2
Ensure that the time on both sides (AD host and Linux system) is synchronized (see chronyd)
To check the time on Rocky Linux:
[user@host~]$date
Wed22Sep17:11:35BST2021
Install the required packages for AD connection on the Linux side:
Once you have successfully discovered your Active Directory installation from the Linux host, you should be able to use realmd to join the domain, which will orchestrate the configuration of sssd using adcli and some other such tools.
[user@host~]$sudorealmjoinad.company.local
If this process complains about encryption with KDC has no support for encryption type, try updating the global crypto policy to allow older encryption algorithms:
getent get entries from Name Service Switch libraries (NSS). It means that, contrary to passwd or dig for example, it will query different databases, including /etc/hosts for getent hosts or from sssd in the getent passwd case.
realm provides some interesting options that you can use:
In a completely default setup, you will need to log in with your AD account by specifying the domain in your username (e.g., john.doe@ad.company.local). If this is not the desired behavior, and you instead want to be able to omit the domain name at authentication time, you can configure SSSD to default to a specific domain.
This is a relatively straightforward process, requiring a configuration tweak in your SSSD configuration file.
By adding the default_domain_suffix, you are instructing SSSD to (if no other domain is specified) infer that the user is trying to authenticate as a user from the ad.company.local domain. This allows you to authenticate as something like john.doe instead of john.doe@ad.company.local.
To make this configuration change take effect, you must restart the sssd.service unit with systemctl.
[user@host~]$sudosystemctlrestartsssd
In the same way, if you don't want your home directories to be suffixed by the domain name, you can add those options into your configuration file /etc/sssd/sssd.conf: