EnterpriseIdentity

Active Directory on Linux

Join a RHEL 9 or Ubuntu 24.04 host to Active Directory with SSSD and InfoPipe, sign in with Kerberos and assign a guardrail profile to an AD group.

This guide joins a Linux host to Active Directory, shows what DefenseClaw records for an AD user, and assigns a guardrail profile to an AD group. DefenseClaw needs nothing from AD beyond a normal domain join. What it reads, and how far each fact can be trusted, is in How DefenseClaw knows who a user is.

Before you start

You needExample in this guide
RHEL 9 or Ubuntu 24.04 with root accesshost.corp.example.com
An AD domain and an account that may join computersCORP.EXAMPLE.COM, administrator
An AD user and groupalice, contractors@corp.example.com
DefenseClaw: a per-user install or the standalone enterprise packageQuickstart, Install on Linux

Join the host and check it

Join the host with SSSD

Install the packages:

sudo dnf install realmd sssd sssd-tools sssd-dbus sssd-kcm adcli samba-common-tools krb5-workstation oddjob oddjob-mkhomedir
sudo apt-get install realmd sssd-ad sssd-tools sssd-dbus sssd-kcm libnss-sss libpam-sss adcli krb5-user
sudo pam-auth-update --enable mkhomedir
sudo hostnamectl set-hostname host.corp.example.com
sudo grep -qxF 'includedir /etc/krb5.conf.d/' /etc/krb5.conf || sudo sed -i '1i includedir /etc/krb5.conf.d/' /etc/krb5.conf
  • krb5-user asks for the default Kerberos realm; enter CORP.EXAMPLE.COM.
  • Set the FQDN before realm join, so the keytab contains host/host.corp.example.com.
  • mkhomedir creates an AD user's home at first sign-in.
  • The includedir line loads SSSD's localauth plugin. Without it a GSSAPI sign-in maps the ticket to alice instead of alice@corp.example.com, and SSH denies the login.

Join the domain and allow the user:

sudo realm discover corp.example.com
sudo realm join --membership-software=adcli --client-software=sssd -U administrator corp.example.com
sudo realm permit alice@corp.example.com

On Ubuntu, also turn on GSSAPI in OpenSSH:

Ubuntu 24.04
printf 'GSSAPIAuthentication yes\n' | sudo tee /etc/ssh/sshd_config.d/50-gssapi.conf
sudo sshd -t
sudo systemctl reload ssh

Turn on InfoPipe

The standalone enterprise guardian reads the UPN through SSSD's InfoPipe D-Bus service, as root. Add it to /etc/sssd/sssd.conf:

[sssd]
services = ifp

[ifp]
user_attributes = +userPrincipalName
OSservices line
RHEL 9services = nss, pam, ifp
Ubuntu 24.04services = ifp only. The NSS and PAM responders are socket activated; listing them makes their sockets fail

If InfoPipe returns no userPrincipalName, also add ldap_user_extra_attrs = userPrincipalName to the [domain/...] section. realm join sets use_fully_qualified_names = True, which these docs assume.

Restart SSSD and check it answers

sudo sss_cache -E
sudo systemctl restart sssd
systemctl is-system-running
getent passwd alice@corp.example.com
id alice@corp.example.com
realm list
sudo dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe org.freedesktop.sssd.infopipe.GetUserAttr string:alice@corp.example.com array:string:userPrincipalName
CommandExpected
systemctl is-system-runningrunning. If degraded, read systemctl --failed first
getent, idThe user and the groups
realm listThe domain with server-software: active-directory. The directory type comes from it, on per-user installs too
dbus-sendThe UPN. Run it as root: InfoPipe answers root only, and a standard user gets AuthFailed: Permission denied. Do not loosen InfoPipe's permissions

Note the group spelling id -Gn prints, such as ml-team@corp.example.com. A groups assignment uses that name.

Sign in with a Kerberos ticket and run an agent

From a client with a ticket, sign in with GSSAPI. ssh -K delegates the ticket, which needs a forwardable one:

kinit -f alice@CORP.EXAMPLE.COM
ssh -K alice@corp.example.com@host.corp.example.com

On the host, run an agent such as Claude Code or Codex for one prompt, then read what DefenseClaw recorded. On a per-user install:

defenseclaw audit export --since 10m \
  | jq -c 'select(.action=="hook_decision") | .structured
      | {user: ."defenseclaw.user.name", domain: ."defenseclaw.user.domain",
         directory: ."defenseclaw.user.directory", source: ."defenseclaw.user.identity.source",
         principal: ."defenseclaw.user.principal",
         kerberos_principal: ."defenseclaw.session.kerberos_principal",
         assurance: ."defenseclaw.user.principal.assurance", session: ."defenseclaw.session.kind",
         agent: ."defenseclaw.agent.identity.id"}' | sort -u

On a managed host, export through the installed gateway as root:

sudo /opt/defenseclaw/bin/defenseclaw-gateway audit export --since 10m \
  | jq -c 'select(.action=="hook_decision") | .structured'
FieldPer-userStandalone enterprise
domaincorp.example.comcorp.example.com
directoryactive_directoryactive_directory
sourcesssdsssd_infopipe
assuranceverifiedverified
sessionsshssh
principal, kerberos_principalnull until you turn on ai_discovery.include_user_principalThe same

See Turn off the principal or the IDE inventory for that setting.

Assign a guardrail profile to an AD group

Define a profile, assign it to the group, then ask the gateway who gets it.

~/.defenseclaw/config.yaml
guardrail:
  mode: observe
  profiles:
    contractors:
      mode: action
      block_at: MEDIUM
  profile_assignments:
    - profile: contractors
      match: {groups: ["contractors@corp.example.com"]}
  default_profile: ""        # "" keeps the global guardrail.* behaviour
defenseclaw config validate
defenseclaw guardrail profile list
defenseclaw guardrail profile explain --user bob@corp.example.com --connector codex   # as bob
  user:    bob@CORP.EXAMPLE.COM (2 group(s))
  profile: contractors
  match:   group (contractors@corp.example.com)
  digest:  sha256:4f460f32fe21aa052aa524027ba08c9f89fe695cbe39cea2fb0252e5e0a738bd
  applies (codex): mode=action block_at=MEDIUM alert_at=pack hilt=off rule_pack=...

How to spell the group:

  • name@domain and DOMAIN\name are one group when the user's verified facts name CORP and corp.example.com as their own domain.
  • One AD group is one selector on every OS. contractors@corp.example.com, CORP\contractors and corp.example.com\contractors select the same group on Linux (SSSD), macOS and Windows, case-insensitively.
  • On Linux, use the name id -Gn prints, or its DOMAIN\name form. On Windows, also the bare name or the SID.
  • Only the user's own domain pairs its NetBIOS and DNS names. A group of another domain never matches, and a group of a trusted domain matches only the spelling the host lists.
  • Users of a child domain match users assignments only when you list their domain in ai_discovery.trusted_ad_child_domains (Child domains of the joined realm).

To write the macOS and Windows spelling in YAML, use single quotes:

DOMAIN\name group selector
match: {groups: ['CORP\contractors']}

On a managed host, deliver the profiles in the machine config and check them with enterprise <os> profile-explain. Precedence, worked scenarios, the audit record and delivery to managed hosts are in User- and group-based policies.

Check it worked

  • profile explain shows match: group with your group name. default means no assignment matched.
  • Check any user, on any install, with the commands in Check what DefenseClaw knows about a user.
  • A group change takes SSSD's cache time plus up to 15 minutes in the gateway. Refresh every account now applies it at once on a managed host.

If something does not answer as expected, see Troubleshooting: Identity.

Next steps