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
| Part | What you need |
|---|---|
| Okta | A 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 |
| Host | RHEL 9 with systemd and root access. Outbound TCP 636 to <org>.ldap.okta.com |
| SSSD | A build that has ldap_use_ppolicy; see step 2 |
| DefenseClaw | A per-user install, or the standalone enterprise package |
Where you run okta-ldap-setup.py | Python 3.9 or later and HTTPS access to your Okta org. It needs no packages |
Set it up
Prepare Okta
-
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 -
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 underou=users,dc=<org>,dc=okta,dc=comand groups underou=groups,dc=<org>,dc=okta,dc=com. -
Create the people as usual:
- the Linux users, ordinary Okta users with passwords, collected in one Okta group (
engineeringbelow); - 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
contractorsandml-research.
- the Linux users, ordinary Okta users with passwords, collected in one Okta group (
-
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
| Command | What it changes in Okta |
|---|---|
posix-schema | Adds the user attributes uidNumber, gidNumber, homeDirectory, loginShell and a unique unixUsername, and the group attribute gidNumber |
assign-posix | Gives 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-role | Creates 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-policy | Creates 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 |
check | Changes 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/bashsets other homes and shells. For homes outside/homeand/var/home, add the parent toenterprise.enrollment.home_rootsbefore enrollment.- Hook enrollment skips accounts with a
nologinorfalseshell (for example/sbin/nologin,/usr/sbin/nologinor/bin/false). - Run it from one admin at a time. Okta does not enforce a unique numeric UID;
checkfinds duplicates. Fix one by clearing the UID on one user's profile and runningassign-posix --user LOGIN. - The host step limits SSSD to IDs 1710000 to 1729999. For another range, pass the same
--id-minand--id-maxtoassign-posixandinstall-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 OktaTo 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,gccand the SSSD build dependencies throughsudo 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.pychanges 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 --oldpackagefor the installed packages, and anexcludepkgsline for/etc/dnf/dnf.confsodnf upgradecannot 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_PASSWORDChoose 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.
| Exit | Meaning |
|---|---|
0 | Success. A dry run: nothing would change |
4 | A dry run: the host would change |
1 | Failure. A wrong bind password, or a sign-on policy that refuses the bind user, stops here and leaves sssd.conf as it was |
2 | Bad arguments |
3 | Failure 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:
- renders
sssd-okta.conf.tmpl, checks it withsssctl config-check, and tests the bind user against Okta whenldapsearchis installed (packageopenldap-clients); - installs
/etc/sssd/sssd.conf(root, mode 0600) and keeps the previous file assssd.conf.bak-<time>. It will not replace ansssd.confit did not write, or a marked file with another SSSD domain, unless you pass--force; - selects the authselect
sssdprofile withwith-mkhomedirand enablesoddjobd; - 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; - restarts SSSD when the config changed and waits for the
oktadomain 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-usersSSSD
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 skippedBy 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 tocontractorsandml-research, and makesokta-standard(block at HIGH) the default. Change the group names, then apply it as root.ensurevalidates 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
guardrailkeys ofuser-config.example.yamlinto~/.defenseclaw/config.yaml, then rundefenseclaw 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 claudecodeOn 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 claudecodematch | Meaning |
|---|---|
group with the group name | The assignment worked |
default | No assignment matched |
default_lookup_failed | An 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.
| Field | Per-user install | Standalone enterprise |
|---|---|---|
user.id, defenseclaw.user.name | The uid and the unixUsername | The same |
Groups (explain subject, defenseclaw.user.group_count) | The user's Okta groups that have a gidNumber | The same |
defenseclaw.user.identity.source, defenseclaw.user.principal.assurance | sssd, verified | The same; sssd_infopipe once the UPN is mapped |
defenseclaw.user.directory | Absent: InfoPipe answers root only | ldap, from the InfoPipe domain provider |
defenseclaw.user.domain | Absent, because the names are not fully qualified | The same |
UPN and defenseclaw.user.principal | Absent | Absent, unless SSSD maps the Okta login to the UPN |
defenseclaw.session.kind, client.address | ssh and the client address, verified through logind | The 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
| Situation | What happens |
|---|---|
| Group change in Okta | It 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 unreachable | Open 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 back | SSSD 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
- SSSD. The installer prints the exact
sssd.conf.bak-<time>it made and the previousauthselectprofile; on a rerun, use that run's backup. After a first install no backup exists: remove/etc/sssd/sssd.confonly after deciding no other service uses it. - authselect. Restore the previous profile with
sudo authselect select <previous profile and features> --force. Stopsssdandoddjobdonly if this kit enabled them. - sshd. Restore the exact
/etc/ssh/sshd_config.d/45-okta-ldap.conf.bak-<time>or remove the drop-in, check withsudo sshd -t, then reload sshd. - Caches. Run
sudo sss_cache -Ebefore stopping SSSD; cached NSS entries can still resolve for about six minutes afterwards. - 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.
User- and group-based policies
Profile keys, precedence, the audit record and delivery to managed hosts.
How DefenseClaw knows who a user is
The OS facts behind a verified identity, and how Okta and Entra users appear.
Identity and authentication
Supported identity types, agent identity, checks and troubleshooting.
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.
Deploy with Microsoft Entra ID
Deploy DefenseClaw with Microsoft Entra ID on Windows, Linux and macOS: pick a setup, prepare the tenant, map groups to guardrail profiles, check records.