# FreeIPA HBAC in Practice: Control SSH Access by User, Group and Host

Source: https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice
Language: en
Published: 2026-09-20
Updated: 2026-11-22

FreeIPA HBAC on Fedora 44: control SSH access by user, group, host and service, with positive and negative tests.

## 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](https://forgeone.solutions/media/identity-c3-01-authenticated-dashboard.png)](https://forgeone.solutions/media/identity-c3-01-authenticated-dashboard.png)

FreeIPA Web UI after authenticated login. Screenshot from the isolated FreeIPA C3 HBAC lab.

## Lab Setup

```bash
Server:        ipa01.example.test
Clients:       client01.example.test, client02.example.test
Domain:        example.test
Realm:         EXAMPLE.TEST
Distribution:  Fedora 44
FreeIPA:       4.13.3
SSSD IPA:      2.13.1
SELinux:       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](https://forgeone.solutions/media/identity-c3-02-hbac-rules-overview.png)](https://forgeone.solutions/media/identity-c3-02-hbac-rules-overview.png)

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](https://forgeone.solutions/media/identity-c3-03-hbac-allow-all-disabled.png)](https://forgeone.solutions/media/identity-c3-03-hbac-allow-all-disabled.png)

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.

```bash
ipa hbacrule-disable allow_all
ipa 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.test
ipa 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-users
ipa hbacrule-add-host linux-ssh-users-to-linux-servers-sshd --hostgroups=linux-servers
ipa hbacrule-add-service linux-ssh-users-to-linux-servers-sshd --hbacsvcs=sshd
```

```bash
Rule name: linux-ssh-users-to-linux-servers-sshd
Enabled: True
User Groups: linux-ssh-users
Host Groups: linux-servers
HBAC Services: sshd
```

[![FreeIPA HBAC rule for linux-ssh-users, linux-servers and sshd](https://forgeone.solutions/media/identity-c3-04-hbac-custom-rule.png)](https://forgeone.solutions/media/identity-c3-04-hbac-custom-rule.png)

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](https://forgeone.solutions/media/identity-c3-05-hbac-user-group.png)](https://forgeone.solutions/media/identity-c3-05-hbac-user-group.png)

FreeIPA user group linux-ssh-users. Screenshot from the isolated FreeIPA C3 HBAC lab.

[![FreeIPA user hbac-allowed as allowed SSH user](https://forgeone.solutions/media/identity-c3-06-hbac-allowed-user.png)](https://forgeone.solutions/media/identity-c3-06-hbac-allowed-user.png)

FreeIPA user hbac-allowed as allowed SSH user. Screenshot from the isolated FreeIPA C3 HBAC lab.

[![FreeIPA user hbac-denied without allowing group membership](https://forgeone.solutions/media/identity-c3-07-hbac-denied-user.png)](https://forgeone.solutions/media/identity-c3-07-hbac-denied-user.png)

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](https://forgeone.solutions/media/identity-c3-08-hbac-host-group.png)](https://forgeone.solutions/media/identity-c3-08-hbac-host-group.png)

FreeIPA host group linux-servers with client hosts. Screenshot from the isolated FreeIPA C3 HBAC lab.

[![FreeIPA host client01.example.test](https://forgeone.solutions/media/identity-c3-09-hbac-client01-host.png)](https://forgeone.solutions/media/identity-c3-09-hbac-client01-host.png)

FreeIPA host client01.example.test. Screenshot from the isolated FreeIPA C3 HBAC lab.

[![FreeIPA host client02.example.test](https://forgeone.solutions/media/identity-c3-10-hbac-client02-host.png)](https://forgeone.solutions/media/identity-c3-10-hbac-client02-host.png)

FreeIPA host client02.example.test. Screenshot from the isolated FreeIPA C3 HBAC lab.

[![FreeIPA HBAC service sshd](https://forgeone.solutions/media/identity-c3-11-hbac-sshd-service.png)](https://forgeone.solutions/media/identity-c3-11-hbac-sshd-service.png)

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.

```bash
ipa hbactest --user=hbac-allowed --host=client01.example.test --service=sshd
ipa hbactest --user=hbac-denied --host=client01.example.test --service=sshd
ipa hbactest --user=hbac-allowed --host=client02.example.test --service=sshd
```

```bash
Access granted: True
Matched rules: linux-ssh-users-to-linux-servers-sshd

Access granted: False
Not 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.

```bash
hbac-allowed
uid=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.

```bash
hbac-denied:*:1847600004:1847600004:HBAC Denied:/home/hbac-denied:/bin/bash
uid=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.

```bash
ipa group-add-member linux-ssh-users --users=hbac-denied
ipa group-remove-member linux-ssh-users --users=hbac-denied
```

```bash
hbac-denied
uid=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.

```bash
ipa hostgroup-add-member linux-servers --hosts=client02.example.test
```

```bash
hbac-allowed
uid=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.

```bash
ipa hbacrule-disable linux-ssh-users-to-linux-servers-sshd
ipa hbacrule-enable linux-ssh-users-to-linux-servers-sshd
sss_cache -E
```

```bash
user: hbac-allowed
action: acct
service: sshd

testing pam_acct_mgmt
pam_acct_mgmt: Success

hbac-allowed
client01.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 |

## 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.

## Technical Acceptance

HBAC is reliable only when allowed and denied access are both tested. A successful login alone does not prove the deny path.

```bash
ipa hbacrule-find
ipa hbacrule-show allow-ops-ssh --all
ipa hbactest --user=opsallowed --host=client01.example.test --service=sshd
ipa hbactest --user=opsdenied --host=client01.example.test --service=sshd
ssh opsallowed@client01.example.test true
ssh opsdenied@client01.example.test true
```

| Area | Check | Result |
| --- | --- | --- |
| HBAC rule | user/group, host/hostgroup and service set | PASS required |
| Positive test | allowed user can log in via SSH | PASS required |
| Negative test | non-allowed user is denied | PASS required |
| Client | SSSD pulls HBAC policy correctly | PASS required |
| Audit | logs show traceable decision | PASS required |

## Do Not Skip This

- HBAC controls access, not privileged commands.
- Test sudo rules separately.
- Always document positive and negative tests.
- Review default allow rules deliberately before production release.

## Hero image

[![FreeIPA HBAC rule overview with disabled allow\_all and custom SSH rule](https://forgeone.solutions/media/identity-c3-02-hbac-rules-overview.png)](https://forgeone.solutions/media/identity-c3-02-hbac-rules-overview.png)

## Author

Mathias Rumbold

## Category

- [Identity & Access](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice?category=identity-access)

## Tags

- [FreeIPA](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice?tags=freeipa)
- [Identity Management](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice?tags=identity-management)
- [Linux](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice?tags=linux)
- [Kerberos](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice?tags=kerberos)
- [Security](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice?tags=security)
- [Red Hat IdM](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice?tags=red-hat-idm)
- [fedora](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice?tags=fedora)

## Need centralized SSH access control?

ForgeOne supports FreeIPA, Red Hat IdM, Linux client integration, SSSD, HBAC, sudo rules, Keycloak and documented identity operations.

[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 (current part)](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice)
6. [FreeIPA sudo rules in practice: delegate commands without root passwords](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)

## Further content

- [FreeIPA](https://forgeone.solutions/en/products/freeipa)
