Debian: System Security Services Daemon (SSSD) and Active Directory

SSSD (System Security Services Daemon) connects a Linux system to a central identity provider such as Active Directory, FreeIPA or plain LDAP. Once joined, domain users log in with their AD credentials, AD groups control who may log in and who gets sudo, home directories are created on first login, and cached credentials keep logins working when no domain controller is reachable. SSSD started as part of the FreeIPA project and is now the standard way Linux systems join AD.

This guide joins a Debian 13 server to Active Directory, explains what each tool does, and leaves you with a configuration that is:

  • Correct for Kerberos: DNS-based discovery, AES-only, no reverse-DNS surprises
  • Access-controlled: only members of specific AD groups may log in, and AD Group Policy logon rights are honoured
  • Admin-friendly: an AD group gets sudo, home directories are created automatically, and logins work offline
  • Self-maintaining: the machine account password rotates, and the host’s DNS record updates itself
  • Tested and debuggable with sssctl, id, kinit and real logins

Tested on: Debian 13 “trixie” with SSSD 2.x, realmd and adcli, against Active Directory with Windows Server 2019/2022/2025 domain controllers. All commands run as root (or with sudo).


Table of contents

  1. Placeholders
  2. realmd, adcli and sssd.conf: who does what?
  3. Prerequisites
  4. Install the packages
  5. Kerberos client configuration
  6. Discover and join the domain
  7. Tune sssd.conf
  8. Access control: who may log in
  9. Home directories, sudo and SSH
  10. Alternative: join with adcli only
  11. Testing
  12. Day-2 operations
  13. Troubleshooting
  14. Checklist

1. Placeholders

PlaceholderMeaning
example.orgYour AD DNS domain
EXAMPLE.ORGYour Kerberos realm: the AD domain in upper case
dc1.example.orgA domain controller (also used as DNS server)
srv01.example.orgThe Debian server being joined
10.20.0.21The server’s IP address
adm-joinerAn AD account with the right to create computer objects in the target OU
OU=Linux,OU=Servers,DC=example,DC=orgThe OU for Linux computer accounts
Linux-Users, Linux-AdminsAD groups: may log in, may log in and use sudo

2. realmd, adcli and sssd.conf: who does what?

Three tools are involved, and they’re easy to confuse:

ToolWhat it doesWhen you use it
adcliCreates the computer account in AD, sets its password, registers its SPNs and writes the keytab /etc/krb5.keytab. That’s the actual “join”. It also rotates the machine password later.Always, either directly or through realmd
realmd (realm command)The convenient front end. It discovers the domain, installs missing packages, calls adcli to join, writes a working sssd.conf, enables SSSD in NSS and PAM, and manages login permissions (realm permit).The recommended way to join interactively
sssd + sssd.confThe daemon that does the daily work: looks up users and groups, authenticates with Kerberos, caches, enforces access. It needs the keytab from the join to talk to AD.Always. Tune its config after the join.

So, to answer the common question:

  • Writing sssd.conf by hand does not join the machine. Without a computer account and keytab, SSSD can’t authenticate to AD. Something has to run the join, which is adcli.
  • realm join uses adcli internally (joined-with-adcli in the config shows it), and then writes sssd.conf for you. It writes it once, at join time. Your later edits to sssd.conf are kept.
  • Recommended flow: realm join first, then tune sssd.conf (section 7). For fully automated deployments without realmd (Ansible, cloud-init), use adcli directly and ship your own sssd.conf (section 10). The result is the same.

3. Prerequisites

Almost every failed AD join comes down to one of these three:

DNS. The server must use the AD DNS servers as its resolvers, and must find the domain controllers through SRV records:

resolvectl status 2>/dev/null | grep -A2 'DNS Servers' || cat /etc/resolv.conf
host -t SRV _ldap._tcp.dc._msdcs.example.org
host -t SRV _kerberos._tcp.example.orgCode language: JavaScript (javascript)

Time. Kerberos refuses tickets when clocks differ by more than 5 minutes. Sync with the domain controllers:

timedatectl            # "System clock synchronized: yes"Code language: PHP (php)

(chrony with server dc1.example.org iburst lines is the robust choice.)

Host name. The server needs a proper FQDN, and must not map it to a loopback address:

hostnamectl set-hostname srv01.example.org
hostname -f            # srv01.example.orgCode language: CSS (css)

The Debian installer writes 127.0.1.1 srv01.example.org srv01 into /etc/hosts. Replace that line with the real address, so Kerberos and DNS updates see the right IP:

10.20.0.21   srv01.example.org   srv01Code language: CSS (css)

Host name length. AD computer names (NetBIOS names) are at most 15 characters. Longer host names get truncated, which can collide with other machines.


4. Install the packages

apt update
apt install realmd sssd sssd-tools libnss-sss libpam-sss adcli \
            krb5-user samba-common-bin packagekit-
PackagePurpose
realmdDomain discovery and join (realm command)
adcliPerforms the actual AD join and machine password rotation
sssd, sssd-toolsThe daemon and its admin tools (sssctl, sss_cache)
libnss-sss, libpam-sssHook SSSD into user lookup (NSS) and login (PAM)
krb5-userkinit, klist for testing
samba-common-binListed by realm discover as required. Provides helper tools realmd can use.

The trailing packagekit- keeps PackageKit from being pulled in. realmd can use it to install packages on its own, but you’ve just installed everything it needs, and a server doesn’t need a package-installing daemon.


5. Kerberos client configuration

AD publishes its domain controllers in DNS, so the Kerberos client needs very little configuration. No [realms] section with hard-coded KDCs: DNS finds them, including new and replaced DCs.

Replace /etc/krb5.conf with:

[libdefaults]
    default_realm = EXAMPLE.ORG

    # Find KDCs via DNS SRV records; map host names to realms via the domain
    dns_lookup_kdc = true
    dns_lookup_realm = false

    # Don't use reverse DNS to build service names (AD PTR records are often incomplete)
    rdns = false
    dns_canonicalize_hostname = fallback

    # AD tickets carry a large PAC: always use TCP
    udp_preference_limit = 0

    ticket_lifetime = 24h
    renew_lifetime = 7d
    forwardable = true

    # AES only: RC4 and DES are obsolete
    permitted_enctypes = aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96

[domain_realm]
    .example.org = EXAMPLE.ORG
    example.org = EXAMPLE.ORG

# Plugin configuration written by SSSD (e.g. localauth for name mapping)
includedir /var/lib/sss/pubconf/krb5.include.d/Code language: PHP (php)

Test it before joining:

kinit adm-joiner@EXAMPLE.ORG
klist                       # a ticket for krbtgt/EXAMPLE.ORG@EXAMPLE.ORG
kdestroyCode language: PHP (php)

The realm in Kerberos is always upper case (EXAMPLE.ORG). The default_realm and the [domain_realm] mapping must name the same realm. A [realms] entry for a different realm, as in many copied configs, silently breaks KDC discovery.


6. Discover and join the domain

6.1 Discover

realm discover example.orgCode language: CSS (css)
example.org
  type: kerberos
  realm-name: EXAMPLE.ORG
  domain-name: example.org
  configured: no
  server-software: active-directory
  client-software: sssd
  required-package: sssd-tools
  required-package: sssd
  required-package: libnss-sss
  required-package: libpam-sss
  required-package: adcli
  required-package: samba-common-binCode language: CSS (css)

configured: no means not joined yet. If discovery fails, the problem is DNS (section 3).

6.2 Join

realm join example.org \
  --user=adm-joiner \
  --computer-ou="OU=Linux,OU=Servers,DC=example,DC=org" \
  --os-name="Debian GNU/Linux" \
  --os-version="13" \
  --automatic-id-mapping=yes \
  --verboseCode language: JavaScript (javascript)
OptionWhy
--user=adm-joinerA delegated account that may create computer objects in the Linux OU. Don’t use a Domain Admin.
--computer-ou=...Puts the computer object where your GPOs and delegation apply, not in the default CN=Computers
--os-name, --os-versionRecorded on the computer object, so AD inventory shows what the machine runs
--automatic-id-mapping=yesSSSD calculates Unix UIDs and GIDs from the AD SIDs (section 7.2). No Unix attributes are needed in AD.

realmd then calls adcli to create the account and keytab, writes /etc/sssd/sssd.conf, enables SSSD in /etc/nsswitch.conf and PAM, and starts the service.

realm list               # configured: kerberos-member
klist -k /etc/krb5.keytab | head      # SRV01$@EXAMPLE.ORG and host/... entriesCode language: PHP (php)

7. Tune sssd.conf

realmd’s sssd.conf works, but it’s generic. Replace /etc/sssd/sssd.conf with a deliberate configuration:

[sssd]
domains = example.org
services = nss, pam, ssh

[domain/example.org]
# --- Identity and authentication: Active Directory -----------------------------
id_provider = ad
auth_provider = ad
chpass_provider = ad
ad_domain = example.org
krb5_realm = EXAMPLE.ORG
realmd_tags = manages-system joined-with-adcli

# --- Access control (section 8) ---------------------------------------------------
access_provider = ad
ad_access_filter = (memberOf:1.2.840.113556.1.4.1941:=CN=Linux-Users,OU=Groups,DC=example,DC=org)
ad_gpo_access_control = enforcing

# --- Names, IDs, home directories ---------------------------------------------------
use_fully_qualified_names = false
fallback_homedir = /home/%u
default_shell = /bin/bash
ldap_id_mapping = true

# --- Offline logins -------------------------------------------------------------
cache_credentials = true
krb5_store_password_if_offline = true
# Cached logins stop working after 14 days without contact to a DC
offline_credentials_expiration = 14

# --- Machine account maintenance ---------------------------------------------------
# Rotate the computer account password every 30 days (uses adcli)
ad_maximum_machine_account_password_age = 30
# Keep the host's A and PTR records in AD DNS current (secure dynamic update)
dyndns_update = true
dyndns_update_ptr = true
dyndns_refresh_interval = 43200Code language: PHP (php)

SSSD refuses to start if the file is readable by anyone but its owner:

chown root:root /etc/sssd/sssd.conf
chmod 0600 /etc/sssd/sssd.conf
sssctl config-check
systemctl restart sssd

7.1 The important settings explained

SettingWhy
id_provider = adUsers and groups come from AD, including nested groups and the primary group
access_provider = ad + ad_access_filterOnly members of Linux-Users (nested membership counts, thanks to the matching rule 1.2.840.113556.1.4.1941) may log in and AD Group Policy logon rights are enforced
ad_gpo_access_control = enforcingGPO “Allow/Deny log on locally / through Remote Desktop Services” apply to console and SSH logins. Leave ad_gpo_default_right at its default: setting it to permit, as older guides did, lets every PAM service the GPO mapping doesn’t know about through.
use_fully_qualified_names = falseUsers log in as jdoe instead of jdoe@example.org. Use true with several trusted domains, or if AD names can collide with local accounts.
fallback_homedir = /home/%uHome directory when AD has none for Unix. Use /home/%u@%d with fully qualified names.
cache_credentials + offline_credentials_expirationLogins keep working during a DC outage, but not forever with a password that may have been changed or revoked
ad_maximum_machine_account_password_age = 30The machine password rotates automatically, just as on Windows clients
dyndns_update = trueThe server keeps its DNS records current through a Kerberos-secured dynamic update. Set to false only if DNS is managed elsewhere.

7.2 ID mapping: set it once, never change it

With ldap_id_mapping = true, SSSD calculates each user’s UID and GID from the AD SID. Every server with the same ID-mapping settings calculates the same numbers, which matters for NFS and shared storage. Older configs often contain lines such as:

ldap_idmap_range_min = 1174405120
ldap_idmap_autorid_compat = trueCode language: JavaScript (javascript)

Those are only needed to match an existing environment, for example machines that used winbind’s autorid before. Pick the settings once for all servers, and never change them afterwards. A change gives every user new UIDs, and all files they own suddenly belong to someone else (or no one).

If your AD maintains real POSIX attributes (uidNumber, gidNumber, unixHomeDirectory, loginShell), set ldap_id_mapping = false to use them instead.


8. Access control: who may log in

Without access control, every AD user can log in to the server. Two approaches:

A. AD access filter plus GPO (recommended, configured in section 7). Membership of Linux-Users is required, and Windows admins keep central control through GPO logon rights. Create and assign a GPO per server group, for example “Allow log on through Remote Desktop Services = Linux-Admins”, to restrict SSH further.

B. realm permit (simpler). realmd switches access_provider to simple and maintains the allow list itself:

realm deny --all
realm permit -g Linux-Users Linux-Admins

This ignores GPOs completely. It suits environments where Windows admins shouldn’t control Linux logins.

Either way, check the result as an admin:

sssctl user-checks jdoe -s sshd       # "pam_acct_mgmt: Success" or "Permission denied"Code language: PHP (php)

9. Home directories, sudo and SSH

9.1 Create home directories on first login

pam-auth-update --enable mkhomedir

New AD users get a home directory with the default permissions from /etc/login.defs (HOME_MODE).

9.2 sudo for an AD group

Create /etc/sudoers.d/50-ad-admins with visudo -f /etc/sudoers.d/50-ad-admins:

# Members of the AD group Linux-Admins may use sudo (with their AD password)
%linux-admins ALL=(ALL:ALL) ALLCode language: PHP (php)

With the AD provider, SSSD reports names in lower case, and sudo compares them literally. Use the group name exactly as id <user> shows it. Names with spaces must be escaped (%domain\ admins). With use_fully_qualified_names = true, write the full name: %linux-admins@example.org.

9.3 SSH

Allow the AD groups in sshd as well. A second, independent check is good defence in depth. Create or extend /etc/ssh/sshd_config.d/50-hardening.conf:

AllowGroups linux-users linux-admins
sshd -t && systemctl reload ssh

Two optional extras:

  • Kerberos single sign-on: with GSSAPIAuthentication yes in sshd, users with a valid ticket (from a domain-joined Windows or Linux client) log in without a password or key. Clients use ssh -K or GSSAPIAuthentication yes.
  • SSH public keys from AD: with services = ..., ssh (already set) and ldap_user_extra_attrs/ldap_user_ssh_public_key pointing at an AD attribute (often altSecurityIdentities), set AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys and AuthorizedKeysCommandUser nobody in sshd. Keys are then managed centrally in AD.

10. Alternative: join with adcli only

For automated deployments, without realmd. The result is identical to section 6, but every file is under your control:

kinit adm-joiner@EXAMPLE.ORG

adcli join \
  --domain=example.org \
  --domain-ou="OU=Linux,OU=Servers,DC=example,DC=org" \
  --login-ccache \
  --host-fqdn=srv01.example.org \
  --os-name="Debian GNU/Linux" \
  --os-version="13" \
  --verbose

kdestroy
klist -k /etc/krb5.keytab | headCode language: CSS (css)

--login-ccache uses the ticket from kinit, so no password appears on the command line or in a script. Then:

  1. Install /etc/krb5.conf (section 5) and /etc/sssd/sssd.conf (section 7). Leave out the realmd_tags line, because realmd didn’t do the join.
  2. chmod 0600 /etc/sssd/sssd.conf && systemctl restart sssd
  3. Enable SSSD for login and home directories: pam-auth-update --enable sss mkhomedir
  4. Check /etc/nsswitch.conf (section 11.1).

To remove the machine from the domain later: adcli delete-computer --domain=example.org (with an admin ticket), or realm leave if realmd did the join.


11. Testing

11.1 Name service and domain status

grep -E '^(passwd|group|shadow):' /etc/nsswitch.conf
# Each line must end with "sss", e.g.:
# passwd:  files systemd sss
# group:   files systemd sss
# shadow:  files sss

sssctl domain-status example.org          # Online status: Online, with active servers listed
id jdoe                                   # uid, gid and AD groups
getent group linux-admins                 # the group and its membersCode language: PHP (php)

11.2 Authentication and access

sssctl user-checks jdoe -a auth -s sshd   # prompts for the AD password, then shows the PAM result
ssh jdoe@srv01.example.org                # real login: home directory gets created
sudo -l -U jdoe                           # sudo rights from the AD groupCode language: PHP (php)

11.3 Negative tests

  • An AD user not in Linux-Users must be refused: Permission denied and access denied in journalctl -u sssd.
  • A wrong password must fail, and must count towards the AD account lockout policy.

11.4 Offline logins

With network access to the DCs blocked (or the server disconnected), a user who logged in before can still log in with their password: sssctl domain-status example.org then shows Offline.


12. Day-2 operations

TaskCommand
Join statusrealm list, sssctl domain-status example.org
Refresh cached users and groups (e.g. after a group change in AD)sss_cache -E
Clear the whole cache (after ID-mapping or config changes)systemctl stop sssd && rm -f /var/lib/sss/db/*.ldb && systemctl start sssd (needs a DC reachable afterwards: cached offline logins are gone)
Check the config after editingsssctl config-check, then systemctl restart sssd
Machine account password ageklist -kt /etc/krb5.keytab (the key version and timestamp change on rotation)
Debug logging, temporarilysssctl debug-level 6, reproduce, read /var/log/sssd/*.log, then sssctl debug-level 0
Leave the domainrealm leave example.org (removes the local configuration). Delete the computer object in AD, too.

Group membership changes take effect on the next login, or after the cache expires (entry_cache_timeout, default 90 minutes). Run sss_cache -E to apply them immediately.


13. Troubleshooting

SymptomCause / fix
realm discover finds nothingDNS: the server doesn’t use the AD DNS servers, or the SRV records aren’t resolvable (section 3)
kinit: Clock skew too greatTime isn’t synchronised with the DCs
kinit: Cannot find KDC for realmdefault_realm doesn’t match the realm in [domain_realm], or DNS lookups fail. Check that the realm is upper case.
Join fails: Insufficient permissionsadm-joiner lacks the right to create computer objects in the target OU
sssd doesn’t start: File ownership and permissions check failedsssd.conf must be 0600 root:root
id jdoe says “no such user”SSSD is offline (sssctl domain-status), sss is missing in /etc/nsswitch.conf, or the user is outside the search base. Check /var/log/sssd/sssd_example.org.log at debug level 6.
Login denied, log says GPO-based access control failed or Access denied by GPOA GPO logon right doesn’t include the user. Fix it in AD, or test with ad_gpo_access_control = permissive, which logs only.
Login denied for a group memberMembership isn’t visible yet (sss_cache -E), or the ad_access_filter DN doesn’t match the group’s real DN
Files owned by numeric UIDs after a config changeID-mapping settings changed (section 7.2). Restore the old values, and clear the cache.
DNS record not updateddyndns_update is off, the DNS zone doesn’t allow secure dynamic updates, or the /etc/hosts line points the FQDN at 127.0.1.1

14. Checklist

  • โ˜ DNS resolvers are the AD DNS servers, and the SRV records for _ldap and _kerberos resolve
  • โ˜ Time is synchronised with the DCs
  • โ˜ The FQDN is set, at most 15 characters before the first dot, and /etc/hosts doesn’t map it to 127.0.1.1
  • โ˜ krb5.conf uses DNS discovery, upper-case realm, rdns = false, TCP and AES only, with no stale [realms] entries
  • โ˜ Joined with a delegated account into a dedicated OU (realm join or adcli join)
  • โ˜ sssd.conf is 0600 root:root and passes sssctl config-check
  • โ˜ Access is limited to an AD group (ad_access_filter or realm permit), and GPO enforcement isn’t weakened with ad_gpo_default_right = permit
  • โ˜ ID-mapping settings are identical on all servers and documented
  • โ˜ Home directories are created on first login (mkhomedir)
  • โ˜ sudo is granted to an AD group in /etc/sudoers.d/, and SSH AllowGroups matches
  • โ˜ The machine password rotates (30 days), and dynamic DNS updates work
  • โ˜ Tests pass: id, a real SSH login, sudo, a non-member refused, and an offline login works