SSSD and Active Directory, Start to Finish: realm, adcli, Keytabs, and Clearing the Cache

root@rhel10:~# realm join --user=Administrator example.com
root@rhel10:~# realm join --user=Administrator example.com # one command, and the box is a domain member

SSSD and Active Directory, Start to Finish
realm, adcli, Keytabs, and Clearing the Cache

Joining a Linux box to Active Directory is three jobs wearing one name: enroll the machine, let users log in, and keep it working when the domain controller is unreachable. SSSD is the broker in the middle — it talks LDAP and Kerberos to the domain controllers, answers NSS and PAM on the local box, and caches identities and credentials so logins still work offline. realm is the setup tool that does the join; adcli is the lower-level tool for when the join needs doing by hand; SSSD itself is the long-running daemon that does the work afterwards. One convention: # means run as root. The examples use the domain example.com and the realm EXAMPLE.COM — substitute your own. Main path is RHEL 8, 9, and 10, with the RHEL 7 differences called out where they matter.

# the short version — the whole join in eight lines
# dnf install -y realmd sssd adcli krb5-workstation oddjob oddjob-mkhomedir samba-common-tools sssd-tools   # the stack, all of it
# systemctl enable --now sssd oddjobd chronyd   # the daemon, the home-directory helper, the clock
# realm discover -v example.com   # can this box even see the domain?
# realm join --user=Administrator example.com   # enroll — computer account, keytab, sssd.conf, authselect
# realm list   # the box is a member now
# id user@example.com   # NSS answers from AD
# su - user@example.com   # PAM answers from AD, home directory created
# sss_cache -E   # when a lookup goes stale, invalidate everything and let it re-fetch
Every command here appears again below, with its explanation. The join itself is the fourth line; everything before it is making sure the join can succeed, and everything after it is proving it did. If you have done this before, the only line that still surprises people is the second one — SSSD ships enabled and does nothing at all until there is a domain to serve, and the clock is the part everyone forgets until Kerberos refuses the ticket.
# the pieces — what each package and service actually does
Package Provides Note
realmd realm The setup tool. Discovers the domain, performs the join, writes the initial config. Not a daemon.
sssd sssd + sssd-ad The broker. LDAP lookups, Kerberos auth, caching, offline login. Ships enabled, inactive until configured.
adcli adcli The low-level join tool. Join, test, update, and pre-stage computer accounts without realmd.
krb5-workstation kinit, klist Kerberos client tools. Not installed by default — install it or there is no way to test tickets by hand.
oddjob + oddjob-mkhomedir oddjobd, pam_oddjob_mkhomedir Creates home directories on first login. Without it, AD users log in to a missing home.
samba-common-tools net, smbclient Only needed for the samba membership path (--membership-software=samba) and for net ads work.
sssd-tools sssctl The diagnostics tool. Not installed by default — install it or there is no sssctl.
authselect authselect Owns PAM and NSS configuration. The join switches its profile to sssd for you.
The services: sssd is the one that runs forever; oddjobd runs alongside it for home directories; chronyd keeps the clock within Kerberos tolerance. realmd is not a service you enable — it is D-Bus activated when you run realm, does the enrollment, and goes away. The commonest missing piece on a fresh box is krb5-workstation: the join works without it, and then the first time you want to check a ticket by hand there is no kinit to run. Install the whole list up front and stop discovering the gaps one error at a time.
# before the join — DNS, time, hostname, ports
# hostname -f   # a real FQDN, e.g. rhel10-01.example.com — the computer account is named after the host
# timedatectl   # NTP synchronized: yes — Kerberos refuses tickets past 5 minutes of skew
# cat /etc/resolv.conf   # nameserver must be an AD DNS server, or one that forwards to it — discovery is DNS SRV records
Three prerequisites, all of them boring, all of them the cause of most failed joins. DNS first: the box must resolve the domain’s SRV records (_kerberos._udp and _ldap._tcp), which live on the AD DNS servers — pointing the box at a public resolver is the single commonest reason realm discover finds nothing. Time second: Kerberos tickets are only valid inside a five-minute window, so the box clock and the domain controller clock must agree; chronyd against the domain controllers or a source they share is the fix, and timedatectl is the check. Hostname third: the computer account takes the hostname, so join with the name you intend to keep — renaming a joined box means leaving and rejoining.
Service Port Protocol Purpose
DNS 53 TCP/UDP SRV discovery, name resolution
Kerberos 88 TCP/UDP Authentication tickets
Kerberos password change 464 TCP/UDP kadmin password changes
LDAP 389 TCP/UDP Directory queries, the join itself
LDAPS 636 TCP Directory queries over TLS
Global Catalog 3268 TCP Forest-wide user and group resolution
SMB 445 TCP Only for the samba membership path
Client to domain controller, all of it. Test a port with nc -vz dc01.example.com 389 (from the nmap-ncat package) — or skip the port checks and let realm discover -v fail fast on the first unreachable service, which amounts to the same test with better error text.
# install — the stack, then the services
# dnf install -y realmd sssd adcli krb5-workstation oddjob oddjob-mkhomedir samba-common-tools sssd-tools   # one line, every tool this post uses
# systemctl enable --now sssd oddjobd chronyd   # sssd does nothing yet — it has no domain — but it is running and ready
# authselect current   # probably minimal or local; the join switches it to sssd
On AlmaLinux 10, realmd, sssd, adcli, and authselect are already on the box — the install line is still worth running, because krb5-workstation, oddjob, oddjob-mkhomedir, samba-common-tools, and sssd-tools are not. Do not hand-edit /etc/pam.d/system-auth or /etc/nsswitch.conf — authselect owns those files and overwrites manual edits the next time it runs. If the mkhomedir feature is ever missing after a join, authselect select sssd with-mkhomedir --force puts it back. On RHEL 7 there is no authselect at all: the equivalent is authconfig --enablesssd --enablesssdauth --enablemkhomedir --update.
# discover — prove the box can see the domain before joining it
# realm discover -v example.com   # verbose discovery: SRV records, domain controllers, the site, what the realm supports
# adcli info example.com   # the same discovery from the lower level: domain, forest, DCs, site
# adcli info --domain-controller=dc01.example.com   # pin one DC when discovery finds the wrong one, or several
Discovery is DNS. realm discover queries the SRV records, finds a domain controller, and reports the domain name, type, and what it can do with it — if it reports nothing, the problem is DNS or ports, not the join command, and no amount of retyping the join will fix it. adcli info is the same check without realmd in the way, and the --domain-controller form is how you aim at one DC specifically, which is what you want when the site has several and discovery keeps picking the far one.
# join — the one command, and what it does behind you
# realm join --user=Administrator example.com   # the account needs permission to create computer accounts — domain admin, or delegated rights
# realm join --user=admin --computer-ou=OU=Linux,DC=example,DC=com example.com   # put the computer account in a chosen OU instead of the default Computers container
# realm list   # the box is a member: domain, configured, server-software, client-software
The join does five things: it creates the computer account in AD, writes the machine keytab to /etc/krb5.keytab, writes /etc/sssd/sssd.conf, writes /etc/krb5.conf, and switches the authselect profile to sssd (adding mkhomedir if oddjob-mkhomedir is installed). The --user account is only needed for the enrollment — it is not stored anywhere on the box. If you already hold a Kerberos ticket (kinit first), run the join without --user and realmd uses the credential cache instead; --user, --no-password, and --one-time-password are mutually exclusive, so pick one. If the domain was preconfigured and no --user is given, an automatic join is attempted first.

The manual join, with adcli

# adcli join --domain-controller=dc01.example.com --add-service-principal=host/rhel10-01.example.com --show-details example.com   # join by hand, with an extra service principal, and print what happened
Use adcli join when realmd is not available or the join needs controlling precisely — which DC, which service principals, what operating system the account advertises (--os-name and --os-version set those fields on the computer account). It does the enrollment and the keytab, and leaves the SSSD configuration to you — that is the next section. --show-details prints the join result in a form both humans and scripts can read, which is worth having the first time you run it against a new domain.
# sssd.conf — what the join writes, and the knobs you will actually turn
[sssd]
services = nss, pam
config_file_version = 2
domains = example.com

[domain/example.com]
id_provider = ad   # users and groups come from AD over LDAP
auth_provider = ad   # passwords are checked against AD over Kerberos
access_provider = ad   # login permission is decided by AD (permit rules and GPO, below)
ad_domain = example.com
ldap_id_mapping = True   # SIDs map to UIDs algorithmically — the default for the ad provider; False only if AD carries POSIX uidNumber/gidNumber
use_fully_qualified_names = False   # log in as user, not user@example.com
fallback_homedir = /home/%u
default_shell = /bin/bash
cache_credentials = True   # cached passwords still work when the DCs are unreachable
enumerate = False   # leave it off — getent still resolves individuals, and full enumeration hammers the DCs on a large domain
ad_gpo_access_control = permissive   # start here; enforcing applies GPO allow/deny strictly, disabled ignores GPOs entirely
That is close to what realm join writes — the three providers, the domain, and the mapping defaults — with the knobs annotated. Two rules about the file itself: it must be owned by root and readable only by root (chmod 0600 /etc/sssd/sssd.conf), and SSSD will not start with a world-readable config. After any hand edit, systemctl restart sssd — and before the restart, sssctl config-check (from sssd-tools) validates the file and reports problems without touching the running daemon. Two options worth knowing by name: ad_server pins a domain controller — leave it unset and SSSD discovers DCs from DNS, which is what you want unless one DC is misbehaving — and ad_access_filter is an LDAP filter that restricts who may log in, for example (memberOf=CN=LinuxAdmins,OU=Groups,DC=example,DC=com). dyndns_update = True makes the box register its own A record in AD DNS, which is off by default and only wanted when the DCs are the DNS servers for the zone.
# keytabs — the machine’s credentials, and how to check them
# klist -k /etc/krb5.keytab   # the principals in the machine keytab — host/ is the computer account itself
# adcli testjoin   # the machine account still authenticates — the first test after any keytab work
# adcli update --add-service-principal=host/rhel10-01.example.com   # add a service principal to the computer account and the keytab
# adcli update --remove-service-principal=host/oldname.example.com   # take one away again
The keytab is the machine’s password, stored as Kerberos keys — the join creates it, SSSD uses it to authenticate the computer account, and nothing else on the box needs to know the password itself. klist -k is the read-only way to see what is in it. The machine account password rotates on its own (SSSD renews it), so a keytab that worked last month and fails today usually means the rotation happened while the box was offline, or the account was reset in AD — adcli testjoin is the test, and rejoining is the fix. Two more keytab facts: the file is root-owned 0600, and it must never be copied to another host — a keytab is bound to the computer account that owns it. Pre-staging is the other half of this section: adcli preset-computer --domain=example.com rhel10-01 creates the computer account in advance, so the join itself can run with an account that only has rights to use a pre-created object, paired with --one-time-password on the join.
# who can log in — permit rules, and GPO versus filter
# realm permit --all   # any domain user may log in — the open door; use it while testing, then narrow it
# realm permit user@example.com   # one user
# realm permit --withdraw user@example.com   # take that user back off the list
# realm deny -a   # deny everyone — the emergency brake, and the starting point for an allow-list
# realm list   # shows the current permit list
Access is decided in two places and they stack. realm permit writes the SSSD allow-list: --all opens the door, a named user opens it for one person, --withdraw takes a name off, and realm deny -a closes it for everyone. The second place is the domain section: ad_access_filter (an LDAP filter, so group membership can be the rule) and ad_gpo_access_control, which applies the domain’s Group Policy allow and deny logon rights. The GPO modes: permissive logs what the GPO would deny but lets the login through — the right starting point while you confirm the GPOs are readable; enforcing applies them strictly; disabled ignores GPOs entirely. If logins fail after a join and the user is permitted, the GPO mode is the first thing to check — enforcing with unreadable GPOs locks everyone out, which is why the sample config above starts permissive.
# clearing the cache — invalidate, or wipe it for real
# sss_cache -E   # invalidate everything — users, groups, the lot; SSSD re-fetches from AD on next lookup
# sss_cache -u user@example.com   # one user only, the rest of the cache untouched
# sss_cache -g group@example.com   # one group
# sss_cache -E -d example.com   # everything, but only for this domain
sss_cache invalidates — it marks the entries stale and SSSD fetches fresh ones from the domain controller on the next lookup. It does not delete the cache files, and for a changed group membership or a renamed user it is the right tool: targeted, no service restart, no offline window. It lives in sssd-common, so it is on the box already.
# sssctl cache-remove   # the real wipe — prompts to stop SSSD, backs the cache up, removes the files, offers to start it again
sssctl cache-remove is the heavy tool, from sssd-tools: it stops SSSD, backs up the local data, removes the cache files, and starts SSSD again. Use it when invalidation does not fix the problem — a corrupted cache, a user who cannot log in after every other check passes, or a domain that was rejoined and SSSD still answers with the old state. The manual equivalent, when you want no prompts, is the same three steps by hand:
# systemctl stop sssd   # stop it first — never delete cache files under a running daemon
# rm -rf /var/lib/sss/db/*   # the cache databases
# systemctl start sssd   # it rebuilds from AD on demand
One warning that belongs with the wipe: clearing the cache also clears cached credentials, so a box that was happily logging users in offline will need a domain controller reachable before the next login works. Invalidate first, wipe second, and only wipe when invalidation has already failed.
# testing the join — prove it, layer by layer
# adcli testjoin   # the machine account authenticates — do this first, it isolates machine problems from user problems
# realm list   # configured, and the permit list
# id user@example.com   # NSS: uid, gid, and groups from AD
# getent passwd user@example.com   # the same answer through the name service switch
# su - user@example.com   # PAM: authentication plus a created home directory
$ id user@example.com
uid=1234567(user) gid=1234567(domain users) groups=1234567(domain users),1234568(linuxadmins)
Test in order, because each layer isolates a different failure: the machine account, then the directory, then the user, then the login. If id works and su - fails, the problem is PAM or access control, not the directory. If id fails, the problem is SSSD or the domain, not PAM. The two deeper tools, both from sssd-tools:
# sssctl domain-status example.com   # Online or Offline, and which DCs SSSD is using
# sssctl user-checks -a acct -s sshd user@example.com   # what NSS and PAM see for this user, and whether the login is authorized
# sssctl config-check   # static validation of sssd.conf before a restart
# kinit user@EXAMPLE.COM   # a ticket by hand — proves Kerberos itself, outside SSSD
# klist   # the ticket is there, with its expiry
sssctl domain-status saying Offline is the single most informative line in SSSD troubleshooting — it means SSSD cannot reach a domain controller, and the fix is DNS, ports, or the DCs themselves, not the config file. user-checks with -a acct -s sshd shows the same decision SSHD will make, before anyone tries to log in. And kinit succeeding while SSSD logins fail splits the problem cleanly in half: Kerberos works, so the fault is in SSSD, its cache, or its access rules.
# when it breaks — the failures, in the order you will meet them

Discovery finds nothing

DNS or ports. Check /etc/resolv.conf points at AD DNS, check the SRV records resolve, check port 389 to a DC. realm discover -v shows which step failed — read its output before retyping anything.

Join fails on the password step

The account lacks rights to create computer accounts, or the password is wrong. Against a recently patched Windows Server 2022 or 2025 domain controller, there is a second cause: a Kerberos regression in those updates breaks the password change adcli performs during the join. Retry with --membership-software=samba on the join, which takes the SMB path instead.

Users resolve but cannot log in

Access control, in this order: the realm permit list, ad_access_filter, then the GPO mode — enforcing with unreadable GPOs locks everyone out, so drop to permissive and retest. sssctl user-checks shows the decision before you test with a real login.

Time skew

Kerberos refuses tickets past five minutes of skew. timedatectl shows whether NTP is synchronized; chronyc tracking shows the offset. Fix the clock, then retest — no config change will help until the time is right.

SSSD says the domain is Offline

sssctl domain-status is the check. Offline means no reachable DC: DNS, ports, or the controllers themselves. While it is offline, cached credentials still work for users who have logged in before — that is the cache earning its keep, not a bug.

Nothing makes sense — turn the logging up

# sssctl config-check   # the config is valid; rule that out first
# journalctl -u sssd --since "10 minutes ago"   # what SSSD has been doing, and failing at
For a stubborn one, set debug_level = 7 in the [sssd] section (and per-domain if needed), restart SSSD, reproduce the failure, and read /var/log/sssd/. The sss_debuglevel tool (in sssd-tools) changes the level on a running daemon without a restart. Turn the level back down when you are done — level 7 on a busy box fills disks. And when the config itself is suspect, the documented recovery is to leave and rejoin: realm leave followed by realm join rebuilds the configuration with defaults, which overwrites hand edits — save those first.
# leaving — unjoin cleanly
# realm leave   # deconfigure the box; the computer account stays in AD
# realm leave --remove   # deconfigure and delete the computer account from AD as well
# adcli delete-computer --domain=example.com rhel10-01   # delete a computer account by hand, without touching the local box
Leaving removes the local configuration — the keytab, the SSSD domain section, the authselect profile change. The computer account in AD is only deleted with --remove, so a plain leave followed by a rejoin reuses the same account, which is usually what you want when you are redoing a broken join. adcli delete-computer is the AD-side cleanup for a box that no longer exists, run from any joined machine. After a leave, remember the local side too: AD users’ home directories stay on disk, and cached credentials stay in the cache until it is cleared — wipe the cache if the box is being repurposed rather than rejoined.
# quick reference — the whole post as a table
I need to… Command
Install the stack dnf install -y realmd sssd adcli krb5-workstation oddjob oddjob-mkhomedir samba-common-tools sssd-tools
Start the services systemctl enable --now sssd oddjobd chronyd
Discover the domain realm discover -v example.com / adcli info example.com
Join the domain realm join --user=Administrator example.com
Join into a chosen OU realm join --user=admin --computer-ou=OU=Linux,DC=example,DC=com example.com
Join by hand with adcli adcli join --domain-controller=dc01.example.com --show-details example.com
See if the box is joined realm list
Test the machine account adcli testjoin
Resolve a user id user@example.com / getent passwd user@example.com
Test a login su - user@example.com
Allow a user / everyone realm permit user@example.com / realm permit --all
Take a user off the list realm permit --withdraw user@example.com
Deny everyone realm deny -a
Check the keytab klist -k /etc/krb5.keytab
Add / remove a service principal adcli update --add-service-principal=host/name / --remove-service-principal=host/name
Pre-stage a computer account adcli preset-computer --domain=example.com rhel10-01
Invalidate the cache sss_cache -E / sss_cache -u user@example.com / sss_cache -E -d example.com
Wipe the cache for real sssctl cache-remove (or stop sssd, rm -rf /var/lib/sss/db/*, start sssd)
Check domain and user state sssctl domain-status example.com / sssctl user-checks -a acct -s sshd user@example.com
Validate the config sssctl config-check
Test Kerberos by hand kinit user@EXAMPLE.COM then klist
Leave the domain realm leave / realm leave --remove
The stack: realmd joins, sssd serves, adcli does the low-level work, krb5-workstation and sssd-tools supply the testing tools — install all of them up front.
The prerequisites: AD DNS, a clock within five minutes, a stable FQDN, and the ports open to the DCs — most failed joins are one of these.
The join: realm join creates the computer account, the keytab, sssd.conf, krb5.conf, and the authselect profile in one step.
The cache: sss_cache invalidates and SSSD re-fetches; sssctl cache-remove wipes for real — invalidate first, wipe second.
The access: permit rules, then ad_access_filter, then GPO mode — start GPO at permissive, not enforcing.
The test order: machine account, then directory, then user, then login — each layer isolates a different failure.

Commands verified November 2026 against the man pages shipped on AlmaLinux 10.3 (realmd 0.17.1, SSSD 2.13.1, adcli 0.9.3.1): realm(8) for discover/join/leave/permit/deny and the --user, --computer-ou, --no-password, --one-time-password, and --remove options; adcli(8) for info/join/update/testjoin/preset-computer/delete-computer and --add-service-principal / --remove-service-principal; sss_cache(8) for -E, -u, -g, -d; sssd-ad(5) and sssd.conf(5) for the domain options, GPO modes, and dyndns_update. Package versions confirmed in the AlmaLinux 10 repos (read-only queries — nothing installed for this post): realmd 0.17.1, sssd 2.13.1, adcli 0.9.3.1, krb5-workstation 1.21.3, oddjob 0.34.7, samba-common-tools 4.24.5, sssd-tools 2.13.1, authselect 1.5.3. sssctl subcommands (domain-status, user-checks, config-check, cache-remove) and the RHEL 7 authconfig form are per the Red Hat System-Level Authentication Guide and the RHEL 10 authentication documentation. No live domain join was performed — the box has no AD domain to join — so the join, lookup, and login outputs are as documented, not as run here.

Series: GuidesPublished: 18 Nov 2026

Scroll to Top