Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 38 ยท Integration and Security

Linux Integration: realm join, SSSD and Kerberos Configuration

Join a Linux server to Active Directory with realmd and SSSD: DNS and time prerequisites, krb5.conf, sssd.conf, UID mapping from SIDs, sudo and SSH access control and troubleshooting.

Most organisations run Linux servers next to Windows, and administrators want the same accounts, the same password and the same groups on both. Active Directory makes that possible because it speaks standard protocols: Kerberos for authentication and LDAP for identity information. A Linux machine only needs software that uses them and caches the results. On modern distributions that software is SSSD (System Security Services Daemon), set up conveniently with realmd.

None of this can run on this site: it needs a Linux machine, root rights and a live domain. Commands and files are therefore read-only, and the runnable examples are small Python stand-ins that lint configuration and compute the user IDs SSSD would assign.

Prerequisites that cause most failures

  1. DNS. The Linux host must use the domain's DNS servers (usually the domain controllers) so it can find _kerberos._tcp.example.com and _ldap._tcp.example.com SRV records. Check with dig SRV _ldap._tcp.example.com.
  2. Time. Kerberos tolerates 5 minutes of skew (why). Run chronyd pointed at a domain controller or a common NTP source.
  3. Hostname. A fully qualified name such as app01.example.com (set with hostnamectl set-hostname).
  4. Ports. The host must reach the DCs on 53, 88, 123, 135, 389, 445, 464, 636 and the dynamic RPC range, depending on what you use.
  5. A join account with permission to create computer objects in the target OU (delegated, not Domain Admin; see administration).

Joining with realmd

Typical steps on a Red Hat style system (read-only):

TEXT
sudo dnf install realmd sssd adcli oddjob oddjob-mkhomedir samba-common-tools krb5-workstation
realm discover example.com
sudo realm join --user=joiner --computer-ou="OU=Linux,OU=Servers,DC=example,DC=com" example.com
realm list
id [email protected]

realm discover finds the domain and the software it needs. realm join creates the computer account, writes the keytab (/etc/krb5.keytab, the machine's long-term Kerberos key), generates /etc/sssd/sssd.conf and enables the service. id [email protected] should then show a UID and the user's groups. To let the home directory appear on first login, enable oddjobd and the mkhomedir PAM option.

The pieces

flowchart LR
  PAM["PAM / sshd / sudo"] --> NSS["NSS: id, getent, ls -l"]
  NSS --> SSSD["SSSD"]
  PAM --> SSSD
  SSSD -- "Kerberos auth (88)" --> DC["Domain controller"]
  SSSD -- "LDAP identity (389/636)" --> DC
  SSSD --> Cache["Local cache (offline login)"]

SSSD answers NSS lookups (who is UID 1234?) and PAM authentication, talks to the DC and keeps a cache, so logins work when the DC is unreachable.

krb5.conf and sssd.conf

/etc/krb5.conf tells the Kerberos client the realm and where KDCs live. With DNS locator records it can be tiny:

TEXT
[libdefaults]
  default_realm = EXAMPLE.COM
  dns_lookup_kdc = true
  rdns = false
  default_ccache_name = KEYRING:persistent:%{uid}

A typical /etc/sssd/sssd.conf written by realmd:

TEXT
[sssd]
domains = example.com
config_file_version = 2
services = nss, pam

[domain/example.com]
ad_domain = example.com
krb5_realm = EXAMPLE.COM
realmd_tags = manages-system joined-with-adcli
cache_credentials = True
id_provider = ad
access_provider = ad
fallback_homedir = /home/%u@%d
use_fully_qualified_names = True
ldap_id_mapping = True
default_shell = /bin/bash

The file must be owned by root with mode 0600, or SSSD refuses to start. Key options:

Option Effect
ldap_id_mapping = True Generate UIDs/GIDs from the user's SID; no POSIX attributes needed in AD
use_fully_qualified_names Users appear as [email protected]; setting False gives short names
access_provider = ad with ad_gpo_access_control Honour Windows logon rights from GPO
simple_allow_groups = linux-admins (with access_provider = simple) Allow only listed groups
cache_credentials Allow offline login after one successful online login
fallback_homedir Home directory template
Python Lint an sssd.conf (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

How SSSD maps SIDs to UIDs

With ldap_id_mapping = True, SSSD computes Linux IDs from the object's SID (for example S-1-5-21-111-222-333-1105). The domain SID prefix selects a slice of 200,000 IDs (range size default 200000, base 200000), and the last part, the RID, is added inside it. Every Linux host with default settings computes the same UID for the same user, which keeps file ownership on NFS shares consistent without storing anything in AD. The algorithm is a hash of the domain SID into a slice number, so different domains get different ranges. The simplified model below uses a fixed slice order to show the arithmetic:

Python SID to UID, simplified (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The consequence: with the real algorithm the same user gets the same ID on all SSSD hosts, but if you need IDs identical to those on non-SSSD systems (older Samba, NIS), store POSIX attributes (uidNumber, gidNumber, unixHomeDirectory, loginShell) in AD and set ldap_id_mapping = False.

Access control and sudo

  • Limit who may log in with realm permit --groups [email protected] (or --all, which you should avoid) and realm deny --all first.
  • Give sudo rights to an AD group through a drop-in file: %[email protected] ALL=(ALL) ALL in /etc/sudoers.d/. Use visudo -f to check syntax.
  • SSH public keys can live in an AD attribute and be returned by SSSD's ssh responder.
  • If GPO-based access control is enabled, Windows Allow log on locally style rights apply to Linux logins as well.

Troubleshooting

Symptom Check
realm join fails with "Insufficient permissions" Delegation on the target OU; try --computer-ou
id user@domain returns nothing sssctl domain-status example.com; DNS; time; sss_cache -E to drop the cache
Login prompts but password rejected Time skew, locked account, ad_gpo_access_control denying
Slow logins Large memberOf, enumeration enabled, unreachable DC; set ad_site or ad_server
Works for a while then fails Machine account password expired; run adcli update

Run sssd in debug (debug_level = 6 in the domain section) and read /var/log/sssd/*.log. Use klist -k to confirm the keytab and kinit [email protected] to test Kerberos on its own, separate from SSSD.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which two protocols does SSSD use to talk to Active Directory?

    Kerberos proves who the user is; LDAP supplies attributes such as groups.
  2. 2. What is the safest way to enable SSSD to assign UIDs without editing AD?

    ID mapping generates consistent IDs from the SID, requiring no POSIX attributes.
  3. 3. What file permissions must /etc/sssd/sssd.conf have?

    SSSD refuses to start with a configuration file that others can read or write.
  4. 4. Why is 'access_provider = permit' dangerous?

    Permit allows any authenticated domain account; restrict with ad or simple providers and groups.
  5. 5. A Linux host's logins fail and klist shows nothing useful. Which prerequisite is the most common culprit?

    Kerberos needs SRV lookups through domain DNS and clocks within 5 minutes.

Summary

  • realmd plus SSSD is the standard way to join Linux to AD; DNS, time and hostname come first.
  • SSSD handles authentication (Kerberos), identity (LDAP), caching and offline login.
  • ID mapping computes UIDs from SIDs; use POSIX attributes only when IDs must match other systems.
  • Restrict logins by group, give sudo through groups, and debug with sssctl, klist and the SSSD logs.

Next: Hardening Active Directory