EnterpriseIdentity

Okta on Linux

Read Okta users and groups on Linux through the Okta LDAP Interface and SSSD, choose guardrail profiles by Okta group and troubleshoot the setup.

DefenseClaw never calls Okta. On Linux, Okta users become operating-system accounts through the Okta LDAP Interface, which SSSD reads like any other LDAP directory. DefenseClaw then sees an Okta user like any SSSD account, and an Okta group can choose that user's guardrail profile. New to how DefenseClaw uses identity? Read Attribution, not authentication first.

Preview

Active Directory is the supported identity stack. Okta on Linux is Preview: it is available but may change. These steps are for RHEL 9, one okta.com org, and an SSSD that has ldap_use_ppolicy.

It works with per-user installs and the standalone enterprise profile. A per-user config is in the user's home, so the user can change their own profile. To enforce one, deliver it in the standalone profile's machine config.

The starter scripts in packaging/identity/okta do each step and can be run again safely.

Requirements

PartWhat you need
OktaA super administrator, to create an API token and turn on the LDAP Interface. Users that sign in with a password: an LDAP bind cannot answer a second-factor prompt
HostRHEL 9 with systemd and root access. Outbound TCP 636 to <org>.ldap.okta.com
SSSDA build that has ldap_use_ppolicy; see step 2
DefenseClawA per-user install, or the standalone enterprise package
Where you run okta-ldap-setup.pyPython 3.9 or later and HTTPS access to your Okta org. It needs no packages

Set it up

Prepare Okta

  1. Create an API token in the Admin Console (Security > API) for a super administrator. Set the org URL; the setup script prompts for the token without echoing it.

    export OKTA_ORG_URL=https://example.okta.com
  2. Turn on the LDAP Interface: Directory > Directory Integrations > Add LDAP Interface. Okta has no API for this step. It then serves ldaps://<org>.ldap.okta.com:636, with users under ou=users,dc=<org>,dc=okta,dc=com and groups under ou=groups,dc=<org>,dc=okta,dc=com.

  3. Create the people as usual:

    • the Linux users, ordinary Okta users with passwords, collected in one Okta group (engineering below);
    • a bind user that SSSD reads the directory with: an ordinary Okta user, not a Linux account, not in the Linux groups;
    • the groups that will choose profiles, for example contractors and ml-research.
  4. Prepare the org with the setup script, from the kit folder, on any machine that can reach your Okta org. A command that writes prints its plan and changes nothing until you add --apply, so run each one without it first.

    ./okta-ldap-setup.py posix-schema --apply
    ./okta-ldap-setup.py assign-posix --users-from engineering --primary-group linux-users \
        --group contractors --group ml-research --apply
    ./okta-ldap-setup.py bind-role --bind-login ldap-bind@example.com --apply
    ./okta-ldap-setup.py signon-policy --bind-login ldap-bind@example.com --group linux-users --apply
    ./okta-ldap-setup.py check --bind-login ldap-bind@example.com --group linux-users \
        --group contractors --group ml-research
CommandWhat it changes in Okta
posix-schemaAdds the user attributes uidNumber, gidNumber, homeDirectory, loginShell and a unique unixUsername, and the group attribute gidNumber
assign-posixGives each selected user a uidNumber (from 1710000), unixUsername, gidNumber, homeDirectory and loginShell, adds them to the primary group, and gives that group and each --group a gidNumber (from 1720000). SSSD skips a group without a gidNumber, such as Okta's built-in Everyone
bind-roleCreates a custom admin role with only okta.users.read and okta.groups.read on all users and groups, and assigns it to the bind user. Without a role the bind user sees only itself
signon-policyCreates a sign-on policy for the LDAP Interface app with two password-only rules (the bind user, and the group) and assigns it. Its catch-all rule still requires a second factor from everyone else
checkChanges nothing. Reports what is ready and what is missing, including a group only partly covered by the sign-on rules

Options and rules for assign-posix:

  • --home-template '/srv/home/{name}' --shell /bin/bash sets other homes and shells. For homes outside /home and /var/home, add the parent to enterprise.enrollment.home_roots before enrollment.
  • Hook enrollment skips accounts with a nologin or false shell (for example /sbin/nologin, /usr/sbin/nologin or /bin/false).
  • Run it from one admin at a time. Okta does not enforce a unique numeric UID; check finds duplicates. Fix one by clearing the UID on one user's profile and running assign-posix --user LOGIN.
  • The host step limits SSSD to IDs 1710000 to 1729999. For another range, pass the same --id-min and --id-max to assign-posix and install-sssd-okta.sh.

Password-only sign-in

An LDAP bind cannot answer a second-factor prompt, so the LDAP Interface needs a rule that accepts a password alone, and SSH sign-in in this guide then needs only the Okta password. The signon-policy rule covers only the bind user, one group and the LDAP Interface app. Anyone else is refused with "Resource owner password credentials authentication denied by sign on policy." Restrict who can reach SSH as for any password login.

Get an SSSD that can bind to Okta

SSSD 2.9, the version in RHEL 9, cannot bind to Okta. It always sends the password-policy request control; Okta answers with an empty response control, and SSSD 2.9 treats that as a failed bind. Upstream SSSD 2.10.0 added the option ldap_use_ppolicy for this. Check your host:

grep ldap_use_ppolicy /usr/share/sssd/cfg_rules.ini    # a match means this SSSD can bind to Okta

To rebuild RHEL 9.8's SSSD with the option, run this as a normal user with sudo on a RHEL 9.8 host:

./build-sssd-ppolicy-backport.sh --workdir "$HOME/sssd-ppolicy-build"
  • It installs rpm-build, gcc and the SSSD build dependencies through sudo dnf (roughly 370 packages), then builds the packages. It does not install them. Build on a separate host or container if the target must stay free of those dependencies.
  • It is pinned to sssd-2.9.8-4.el9_8.1. backport-ppolicy.py changes the source by exact text replacement and stops at the first text it does not find, so on any other SSSD release it fails instead of building something wrong.
  • When it finishes it prints the install commands: rpm -Uvh --oldpackage for the installed packages, and an excludepkgs line for /etc/dnf/dnf.conf so dnf upgrade cannot put the stock build back.

You own this package

The rebuilt packages are a local fork of a Red Hat package. Red Hat does not support them, and you rebuild them for each later SSSD security update until you can move to an SSSD that has the option.

Configure the host

install-sssd-okta.sh configures SSSD, PAM and sshd on a RHEL-family host. It reads the bind password from a file (mode 0600), from OKTA_BIND_PASSWORD or at a prompt, never from the command line. Run as root, dry run first, then clear the variable:

read -rsp 'Okta bind password: ' OKTA_BIND_PASSWORD; printf '\n'
export OKTA_BIND_PASSWORD
sudo --preserve-env=OKTA_BIND_PASSWORD ./install-sssd-okta.sh --org example \
    --bind-login ldap-bind@example.com --allow-group linux-users --dry-run
sudo --preserve-env=OKTA_BIND_PASSWORD ./install-sssd-okta.sh --org example \
    --bind-login ldap-bind@example.com --allow-group linux-users
unset OKTA_BIND_PASSWORD

Choose an Okta group name absent from the host's /etc/group. The installer rejects a local name collision, because the sshd group rule would also allow password sign-in for members of the local group.

ExitMeaning
0Success. A dry run: nothing would change
4A dry run: the host would change
1Failure. A wrong bind password, or a sign-on policy that refuses the bind user, stops here and leaves sssd.conf as it was
2Bad arguments
3Failure before any change: the host is not RHEL family, a package is missing (--install-packages installs it), python3 is missing, SSSD has no ldap_use_ppolicy, /etc/group cannot be read or the allowed group is a local group, sssd.conf was not written by this script or also configures another SSSD domain, or authselect uses a custom or winbind profile. --force replaces sssd.conf or the authselect profile anyway, and --no-pam skips the authselect step

Without the bind password, a dry run skips the bind test and the config plan. The installer:

  1. renders sssd-okta.conf.tmpl, checks it with sssctl config-check, and tests the bind user against Okta when ldapsearch is installed (package openldap-clients);
  2. installs /etc/sssd/sssd.conf (root, mode 0600) and keeps the previous file as sssd.conf.bak-<time>. It will not replace an sssd.conf it did not write, or a marked file with another SSSD domain, unless you pass --force;
  3. selects the authselect sssd profile with with-mkhomedir and enables oddjobd;
  4. writes /etc/ssh/sshd_config.d/45-okta-ldap.conf, so members of the allowed group sign in with their Okta password and everyone else keeps the sshd default;
  5. restarts SSSD when the config changed and waits for the okta domain to be Online.

A second run with the same options reports every step as unchanged. On another distribution, --render-only FILE writes and checks the SSSD config for you to install. Names are bare (alice, ml-research) unless you set use_fully_qualified_names.

Check the accounts

verify-okta-identity.sh only reads. Run it as root for every check, or as a normal user for the account checks. It asks the SSSD NSS source explicitly, so a local account with the same name does not pass:

sudo ./verify-okta-identity.sh --user alice --expect-group ml-research --allow-group linux-users
SSSD
PASS  sssd service is active
PASS  this SSSD knows ldap_use_ppolicy (it can bind to Okta)
PASS  the allowed group linux-users resolves
PASS  SSSD domain okta is Online
PASS  /etc/sssd/sssd.conf is root:root 0600
User alice
PASS  SSSD passwd: uid 1710001, gid 1720000, home /home/alice
      groups: linux-users ml-research
PASS  id -Gn lists ml-research
      DefenseClaw: profile okta-observe, match group (ml-research), 2 group(s) seen
PASS  DefenseClaw resolved alice to profile okta-observe (match group)

Result: 8 passed, 0 failed, 0 skipped

By hand: getent passwd alice, id alice, sudo sssctl domain-status okta -o and an SSH sign-in with the Okta password.

Install DefenseClaw and deliver the profiles

Install DefenseClaw for the Okta users as for any Linux user: a per-user install for each user, or the standalone enterprise package. Then give it profiles that name the Okta groups as id -Gn prints them. Matching ignores case, so avoid groups whose names differ only by case.

  • Standalone enterprise profile. Start from admin-config.example.yaml. It sets three profiles, assigns two of them to contractors and ml-research, and makes okta-standard (block at HIGH) the default. Change the group names, then apply it as root. ensure validates the file first and keeps the installed config when it is invalid.

    sudo /opt/defenseclaw/bin/defenseclaw-gateway enterprise linux ensure \
        --config /root/defenseclaw-config.yaml --json
  • Per-user install. Merge the guardrail keys of user-config.example.yaml into ~/.defenseclaw/config.yaml, then run defenseclaw config validate. The running gateway applies the change on its next reload.

Both examples use only built-in settings (mode, block_at), so they need no rule pack. Profile keys, precedence and the audit record are in User- and group-based policies. Set a strict default_profile for accounts no assignment selects.

Confirm the profile

sudo ./verify-okta-identity.sh --user alice --expect-profile okta-observe --connector claudecode
sudo ./verify-okta-identity.sh --user bob --expect-profile okta-strict --connector claudecode

On a managed host, run it as root; it calls enterprise linux profile-explain. On a per-user install, run it as the user whose gateway you want to ask; it calls defenseclaw guardrail profile explain, which explains only that user's own account. The commands also work on their own:

defenseclaw guardrail profile explain --user alice --connector claudecode
sudo /opt/defenseclaw/bin/defenseclaw-gateway enterprise linux profile-explain --user alice --connector claudecode
matchMeaning
group with the group nameThe assignment worked
defaultNo assignment matched
default_lookup_failedAn identity fact was not confirmed. When an assignment needs it, the request is refused and names that fact; otherwise the proven or default profile applies

What DefenseClaw records

Read a record with defenseclaw audit export, as in Active Directory on Linux.

FieldPer-user installStandalone enterprise
user.id, defenseclaw.user.nameThe uid and the unixUsernameThe same
Groups (explain subject, defenseclaw.user.group_count)The user's Okta groups that have a gidNumberThe same
defenseclaw.user.identity.source, defenseclaw.user.principal.assurancesssd, verifiedThe same; sssd_infopipe once the UPN is mapped
defenseclaw.user.directoryAbsent: InfoPipe answers root onlyldap, from the InfoPipe domain provider
defenseclaw.user.domainAbsent, because the names are not fully qualifiedThe same
UPN and defenseclaw.user.principalAbsentAbsent, unless SSSD maps the Okta login to the UPN
defenseclaw.session.kind, client.addressssh and the client address, verified through logindThe same

The Okta login as the UPN (standalone enterprise only). The Okta LDAP Interface has no userPrincipalName; its uid is the Okta login. Run install-sssd-okta.sh with --map-upn, which adds ldap_user_principal = uid to the domain and user_attributes = +mail, +userPrincipalName to [ifp]. The guardian then records the Okta login (alice@example.com) as the UPN, with source sssd_infopipe, within its 15-minute refresh. The principal leaves the host only with ai_discovery.include_user_principal: true.

In operation

SituationWhat happens
Group change in OktaIt reaches the host when SSSD's entry expires (entry_cache_timeout, 600 seconds), then the gateway's 15-minute cache, with no new sign-in. sss_cache -E makes SSSD ask Okta at once. profile explain asks the OS directly and refreshes the gateway's cache, so the account's next hook uses the new profile
Okta unreachableOpen sessions with a warm SSSD cache keep their profiles and blocks. New SSH password sign-ins fail, because the kit sets cache_credentials = false. With no cached entry, an assignment that needs the missing fact refuses with default_lookup_failed
Okta backSSSD retries an offline domain at a growing interval (offline_timeout, 60 seconds, doubling up to offline_timeout_max), so it can take several minutes to report Online. sudo systemctl restart sssd brings it back at once. Group profiles apply again shortly after SSSD is Online, with no gateway restart

A managed profile-explain prints a cache object (age_seconds, refresh_after_seconds, differs); a per-user guardrail profile explain prints a cache: line.

macOS and Windows

This kit covers Linux hosts. On other platforms DefenseClaw reports what the operating system knows; see How Okta and Entra users appear. AD-joined Windows and Macs with Okta provisioning users into AD show the AD account. Okta provisioning into AD, Entra federation with Okta, and Platform SSO or Okta Device Access with Okta Verify (directory okta, standalone enterprise only) are Preview.

Troubleshooting

Identity problems and their fixes are in Troubleshooting: Okta on Linux.

Undo

  1. SSSD. The installer prints the exact sssd.conf.bak-<time> it made and the previous authselect profile; on a rerun, use that run's backup. After a first install no backup exists: remove /etc/sssd/sssd.conf only after deciding no other service uses it.
  2. authselect. Restore the previous profile with sudo authselect select <previous profile and features> --force. Stop sssd and oddjobd only if this kit enabled them.
  3. sshd. Restore the exact /etc/ssh/sshd_config.d/45-okta-ldap.conf.bak-<time> or remove the drop-in, check with sudo sshd -t, then reload sshd.
  4. Caches. Run sudo sss_cache -E before stopping SSSD; cached NSS entries can still resolve for about six minutes afterwards.
  5. Okta. Remove only objects you created: the sign-on policy and its rules (first assign the app another policy), the role and resource set, and the users' POSIX attributes and groups.