# FreeIPA sudo rules in practice: delegate commands without root passwords

Source: https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice
Language: en
Published: 2026-10-09
Updated: 2026-11-21

Delegate commands through FreeIPA, configure SSSD correctly and test allow/deny behavior on Fedora.

## Overview

Part 6 of the Identity series shows FreeIPA sudo rules in practice on Fedora 44. The goal is auditable delegation: an operator may inspect the sshd status on a defined client, but cannot restart the service, and users outside the group do not receive that privilege.

Important: HBAC decides whether a user may access a host and service at all. Sudo then decides which privileged commands are allowed on that host. They belong together, but they are not the same control.

[![FreeIPA Web UI after login in the Fedora 44 sudo lab](https://forgeone.solutions/media/01-freeipa-dashboard-fedora.png)](https://forgeone.solutions/media/01-freeipa-dashboard-fedora.png)

FreeIPA Web UI after login in the Fedora 44 sudo lab. Screenshot from the isolated FreeIPA C4 sudo lab on Fedora 44.

## Lab Setup

```bash
Server:        ipa01.example.test
Client:        client01.example.test
Domain:        example.test
Realm:         EXAMPLE.TEST
Distribution:  Fedora Linux 44
Kernel:        6.19.14-300.fc44.x86_64
SELinux:       Enforcing
```

## Object Model

The lab does not use local sudoers files for the functional permission. The rule is modeled centrally in FreeIPA: user group, host group, sudo command, sudo command group and sudo rule.

```bash
ipa group-add ops-sudo-status \
  --desc='Operators allowed to inspect selected service status'
ipa group-add-member ops-sudo-status --users=opsallowed

ipa hostgroup-add linux-clients \
  --desc='Linux clients using central sudo policy'
ipa hostgroup-add-member linux-clients --hosts=client01.example.test

ipa sudocmd-add '/usr/bin/systemctl status sshd'
ipa sudocmdgroup-add service-status-commands \
  --desc='Read-only service status commands'
ipa sudocmdgroup-add-member service-status-commands \
  --sudocmds='/usr/bin/systemctl status sshd'

ipa sudorule-add allow-service-status \
  --desc='Allow status inspection of sshd on Linux clients'
ipa sudorule-add-user allow-service-status --groups=ops-sudo-status
ipa sudorule-add-host allow-service-status --hostgroups=linux-clients
ipa sudorule-add-allow-command allow-service-status \
  --sudocmdgroups=service-status-commands
ipa sudorule-add-runasuser allow-service-status --users=root
ipa sudorule-add-option allow-service-status --sudooption='!authenticate'
```

[![FreeIPA sudo rule allow-service-status with user group, host group, command group and RunAs root](https://forgeone.solutions/media/03-freeipa-sudo-rule-allow-service-status-fedora.png)](https://forgeone.solutions/media/03-freeipa-sudo-rule-allow-service-status-fedora.png)

FreeIPA sudo rule allow-service-status with user group, host group, command group and RunAs root. Screenshot from the isolated FreeIPA C4 sudo lab on Fedora 44.

[![FreeIPA group ops-sudo-status with the allowed operator](https://forgeone.solutions/media/04-freeipa-group-ops-sudo-status-fedora.png)](https://forgeone.solutions/media/04-freeipa-group-ops-sudo-status-fedora.png)

FreeIPA group ops-sudo-status with the allowed operator. Screenshot from the isolated FreeIPA C4 sudo lab on Fedora 44.

[![FreeIPA host group linux-clients with client01.example.test](https://forgeone.solutions/media/05-freeipa-hostgroup-linux-clients-fedora.png)](https://forgeone.solutions/media/05-freeipa-hostgroup-linux-clients-fedora.png)

FreeIPA host group linux-clients with client01.example.test. Screenshot from the isolated FreeIPA C4 sudo lab on Fedora 44.

[![FreeIPA sudo command group service-status-commands](https://forgeone.solutions/media/06-freeipa-sudocmdgroup-service-status-fedora.png)](https://forgeone.solutions/media/06-freeipa-sudocmdgroup-service-status-fedora.png)

FreeIPA sudo command group service-status-commands. Screenshot from the isolated FreeIPA C4 sudo lab on Fedora 44.

## Client Integration Through SSSD

For sudo to see centralized rules, the client must query sudo rules through SSSD. In the lab, \`sudoers: files sss\`, the SSSD sudo responder and a cache refresh were part of the acceptance check.

```bash
# /etc/nsswitch.conf
sudoers:    files sss

# /etc/sssd/sssd.conf
[sssd]
services = nss, pam, ssh, sudo

[sudo]

systemctl restart sssd
sss_cache -E
```

```text
User opsallowed may run the following commands on client01:
    (root) NOPASSWD: /usr/bin/systemctl status sshd

User opsdenied is not allowed to run sudo on client01.
```

## Positive Test

The opsallowed user is a member of ops-sudo-status. \`sudo -l\` shows only the allowed command. \`SYSTEMD\_PAGER=cat\` makes the systemd status output non-interactive and scriptable.

```text
uid=289600003(opsallowed) gid=289600003(opsallowed) groups=289600003(opsallowed),289600005(ops-sudo-status)

User opsallowed may run the following commands on client01:
    (root) NOPASSWD: /usr/bin/systemctl status sshd

SYSTEMD_PAGER=cat sudo -n /usr/bin/systemctl status sshd
Active: active (running)
rc=0
```

## Negative Tests

opsallowed may read the service status but may not execute \`systemctl restart sshd\`. opsdenied resolves as an IPA user, but receives no sudo grant from the FreeIPA rule.

```text
sudo -n /usr/bin/systemctl restart sshd
sudo: a password is required
restart_rc=1

uid=289600004(opsdenied) gid=289600004(opsdenied) groups=289600004(opsdenied)
SYSTEMD_PAGER=cat sudo -n /usr/bin/systemctl status sshd
sudo: a password is required
denied_user_rc=1
```

## Result Check

| Area | Check | Result |
| --- | --- | --- |
| Platform | Server and client on Fedora Linux 44 | PASS |
| FreeIPA | sudo rule allow-service-status exists | PASS |
| Scope | user group ops-sudo-status linked | PASS |
| Scope | host group linux-clients linked | PASS |
| Scope | only /usr/bin/systemctl status sshd allowed | PASS |
| SSSD | sudoers: files sss and sudo responder active | PASS |
| Allow | opsallowed may read sshd status as root | PASS |
| Deny | opsallowed may not restart sshd | PASS |
| Deny | opsdenied receives no sudo grant | PASS |

## Practice Notes

- \`!authenticate\` results in NOPASSWD behavior and should only be used where operational benefit and risk are documented.
- After rule changes, SSSD cache and sudo refresh timing can become visible. For tests, \`sss\_cache -E\` plus an SSSD restart is useful; in production, cache behavior should be planned deliberately.
- For production roles, keep commands narrow and avoid broad root privileges through generic groups.

## Hero image

[![FreeIPA sudo rule allow-service-status with user group, host group, command group and RunAs root](https://forgeone.solutions/media/03-freeipa-sudo-rule-allow-service-status-fedora.png)](https://forgeone.solutions/media/03-freeipa-sudo-rule-allow-service-status-fedora.png)

## Author

Mathias Rumbold

## Category

- [Identity & Access](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice?category=identity-access)

## Tags

- [FreeIPA](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice?tags=freeipa)
- [Identity Management](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice?tags=identity-management)
- [Linux](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice?tags=linux)
- [Kerberos](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice?tags=kerberos)
- [Security](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice?tags=security)
- [Red Hat IdM](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice?tags=red-hat-idm)
- [fedora](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice?tags=fedora)

## Need clean centralized Linux privilege control?

ForgeOne supports FreeIPA, Red Hat IdM, SSSD, HBAC, sudo rules and auditable identity acceptance.

[Discuss an identity project](https://forgeone.solutions/en/contact)

## Identity Management mit FreeIPA und Keycloak

Die Beiträge bauen praktisch aufeinander auf: Fedora-44-basierter FreeIPA-Server, Linux-Clients, Identity-Lifecycle, Passwort-Richtlinien, HBAC, sudo-Regeln, Kerberos-Keytabs, Updates, Backup, Recovery und Hochverfügbarkeit.

1. [Installing FreeIPA: From the First Server to an Enrolled Linux Client](https://forgeone.solutions/en/tech/install-freeipa)
2. [Connect Linux Clients to FreeIPA: SSSD, Kerberos and Centralized Users](https://forgeone.solutions/en/tech/connect-linux-clients-freeipa-sssd-kerberos-centralized-users)
3. [Managing FreeIPA Users and Groups: Identity Lifecycle in Practice](https://forgeone.solutions/en/tech/managing-freeipa-users-groups-identity-lifecycle-practice)
4. [FreeIPA Password Policies in Practice: Expiration, Lockout and Authentication Behavior](https://forgeone.solutions/en/tech/freeipa-password-policies-expiration-lockout-practice)
5. [FreeIPA HBAC in Practice: Control SSH Access by User, Group and Host](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice)
6. [FreeIPA sudo rules in practice: delegate commands without root passwords (current part)](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice)
7. [Kerberos service principals and keytabs with FreeIPA in practice](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice)
8. [Updating FreeIPA: package updates, replicas and client compatibility checks](https://forgeone.solutions/en/tech/freeipa-update-package-updates-replicas-client-compatibility)
9. [FreeIPA backup in practice: ipa-backup, certificates, LDAP and recovery windows](https://forgeone.solutions/en/tech/freeipa-backup-ipa-backup-certificates-ldap-recovery)
10. [FreeIPA disaster recovery: restore, replica rebuilds and emergency access testing](https://forgeone.solutions/en/tech/freeipa-disaster-recovery-restore-replica-rebuild-emergency-access)
11. [Running FreeIPA highly available: replication, CA roles, DNS and maintenance workflows](https://forgeone.solutions/en/tech/freeipa-high-availability-replication-ca-dns-maintenance)
