Overview
Part 5 of the Identity series tests FreeIPA Host-Based Access Control in practice. The goal is not just a nice rule in the Web UI, but proven client behavior: who can SSH to which host, who is denied and what happens when user groups, host groups and rules change?
CLI output is rendered as text and code blocks. Screenshots show the FreeIPA Web UI and come only from the C3 HBAC lab.
FreeIPA Web UI after authenticated login. Screenshot from the isolated FreeIPA C3 HBAC lab.
Lab Setup
Server: ipa01.example.testClients: client01.example.test, client02.example.testDomain: example.testRealm: EXAMPLE.TESTFreeIPA: 4.13.3SSSD IPA: 2.13.1SELinux: Enforcing
Why allow_all Is Not the Target State
FreeIPA ships with an allow_all rule. For targeted access control, that rule must be disabled or deliberately accounted for. The lab disabled allow_all and replaced it with a specific SSH rule.
FreeIPA HBAC rule overview with disabled allow_all and custom SSH rule. Screenshot from the isolated FreeIPA C3 HBAC lab.
FreeIPA HBAC allow_all rule is disabled. Screenshot from the isolated FreeIPA C3 HBAC lab.
Building an SSH HBAC Rule
The rule connects three things: a user group, a host group and the sshd service. Only when all three match is SSH access allowed.
ipa hbacrule-disable allow_allipa group-add linux-ssh-users --desc='Users allowed to access Linux servers over SSH'ipa hostgroup-add linux-servers --desc='Linux servers targeted by HBAC SSH rule'ipa hostgroup-add-member linux-servers --hosts=client01.example.testipa hbacrule-add linux-ssh-users-to-linux-servers-sshd \--desc='Allow linux-ssh-users to use sshd on linux-servers'ipa hbacrule-add-user linux-ssh-users-to-linux-servers-sshd --groups=linux-ssh-usersipa hbacrule-add-host linux-ssh-users-to-linux-servers-sshd --hostgroups=linux-serversipa hbacrule-add-service linux-ssh-users-to-linux-servers-sshd --hbacsvcs=sshd
Rule name: linux-ssh-users-to-linux-servers-sshdEnabled: TrueUser Groups: linux-ssh-usersHost Groups: linux-serversHBAC Services: sshd
FreeIPA HBAC rule for linux-ssh-users, linux-servers and sshd. Screenshot from the isolated FreeIPA C3 HBAC lab.
User Group and Users
The hbac-allowed user is a member of linux-ssh-users. The hbac-denied user also exists and resolves through SSSD, but initially has no allowing group membership.
FreeIPA user group linux-ssh-users. Screenshot from the isolated FreeIPA C3 HBAC lab.
FreeIPA user hbac-allowed as allowed SSH user. Screenshot from the isolated FreeIPA C3 HBAC lab.
FreeIPA user hbac-denied without allowing group membership. Screenshot from the isolated FreeIPA C3 HBAC lab.
Host Group and SSH Service
The linux-servers host group initially contains client01.example.test. client02.example.test is added later to verify that changing the host group changes real SSH access.
FreeIPA host group linux-servers with client hosts. Screenshot from the isolated FreeIPA C3 HBAC lab.
FreeIPA host client01.example.test. Screenshot from the isolated FreeIPA C3 HBAC lab.
FreeIPA host client02.example.test. Screenshot from the isolated FreeIPA C3 HBAC lab.
FreeIPA HBAC service sshd. Screenshot from the isolated FreeIPA C3 HBAC lab.
Prediction with ipa hbactest
ipa hbactest is useful, but it is not the final acceptance gate. The lab used it as a prediction and then validated the result with real SSH connections.
ipa hbactest --user=hbac-allowed --host=client01.example.test --service=sshdipa hbactest --user=hbac-denied --host=client01.example.test --service=sshdipa hbactest --user=hbac-allowed --host=client02.example.test --service=sshd
Access granted: TrueMatched rules: linux-ssh-users-to-linux-servers-sshdAccess granted: FalseNot matched rules: linux-ssh-users-to-linux-servers-sshd
Real SSH Allow Test
The allowed user could SSH to client01.example.test. This proves that FreeIPA, SSSD, PAM and OpenSSH work together.
hbac-alloweduid=1847600003(hbac-allowed) gid=1847600003(hbac-allowed) groups=1847600003(hbac-allowed),1847600006(linux-ssh-users)client01.example.test/home/hbac-allowed
Real SSH Deny Test
The unauthorized user was visible through getent and id, but SSH access was denied. This distinction matters: identity lookup is not the same as permitted login.
hbac-denied:*:1847600004:1847600004:HBAC Denied:/home/hbac-denied:/bin/bashuid=1847600004(hbac-denied) gid=1847600004(hbac-denied) groups=1847600004(hbac-denied)
User Group Changes Affect SSH
After adding hbac-denied to linux-ssh-users, SSH access worked. After removing the membership, access was denied again.
ipa group-add-member linux-ssh-users --users=hbac-deniedipa group-remove-member linux-ssh-users --users=hbac-denied
hbac-denieduid=1847600004(hbac-denied) gid=1847600004(hbac-denied) groups=1847600004(hbac-denied),1847600006(linux-ssh-users)client01.example.test/home/hbac-denied
Host Group Changes Affect SSH
client02.example.test was initially outside linux-servers and denied. After adding the host to the group, access worked.
ipa hostgroup-add-member linux-servers --hosts=client02.example.test
hbac-alloweduid=1847600003(hbac-allowed) gid=1847600003(hbac-allowed) groups=1847600003(hbac-allowed),1847600006(linux-ssh-users)client02.example.test/home/hbac-allowed
Disable and Re-enable the Rule
Disabling the custom HBAC rule denied access. After re-enabling it and refreshing SSSD, access was restored.
ipa hbacrule-disable linux-ssh-users-to-linux-servers-sshdipa hbacrule-enable linux-ssh-users-to-linux-servers-sshdsss_cache -E
user: hbac-allowedaction: acctservice: sshdtesting pam_acct_mgmtpam_acct_mgmt: Successhbac-allowedclient01.example.test/home/hbac-allowed
Result Check
| Area | Check | Expected result | Status |
|---|---|---|---|
| HBAC | disable allow_all | Blanket access is off | PASS |
| HBAC | custom SSH rule | User group, host group and sshd are linked | PASS |
| Prediction | ipa hbactest | Allow and deny cases match | PASS |
| SSH | allowed user | Login to allowed host works | PASS |
| SSH | unauthorized user | Identity lookup yes, SSH no | PASS |
| SSH | host outside host group | Login is denied | PASS |
| Changes | change user group | SSH access follows group membership | PASS |
| Changes | change host group | SSH access follows host group membership | PASS |
| Recovery | disable/enable rule | Deny and recovery work | PASS |
| Web UI | authenticated screenshots | HBAC objects visible | PASS |
HBAC
- Check
- disable allow_all
- Expected result
- Blanket access is off
- Status
- PASS
HBAC
- Check
- custom SSH rule
- Expected result
- User group, host group and sshd are linked
- Status
- PASS
Prediction
- Check
- ipa hbactest
- Expected result
- Allow and deny cases match
- Status
- PASS
SSH
- Check
- allowed user
- Expected result
- Login to allowed host works
- Status
- PASS
SSH
- Check
- unauthorized user
- Expected result
- Identity lookup yes, SSH no
- Status
- PASS
SSH
- Check
- host outside host group
- Expected result
- Login is denied
- Status
- PASS
Changes
- Check
- change user group
- Expected result
- SSH access follows group membership
- Status
- PASS
Changes
- Check
- change host group
- Expected result
- SSH access follows host group membership
- Status
- PASS
Recovery
- Check
- disable/enable rule
- Expected result
- Deny and recovery work
- Status
- PASS
Web UI
- Check
- authenticated screenshots
- Expected result
- HBAC objects visible
- Status
- PASS
Limits of This Lab
The lab tests HBAC for SSH and the sshd service. Other services require separate validation.
Production environments need a role model, break-glass access and documented recovery processes.
The Web UI screenshots used a local CONNECT proxy so the browser could use the canonical FreeIPA hostname without binding a privileged port.






