Web Security

Build a centralized authentication server for Linux with FreeIPA

Build a centralized authentication server for Linux with FreeIPA

Updated October 2026 for FreeIPA on AlmaLinux 9 / Rocky Linux 9 and SSSD clients on AlmaLinux 9 and Ubuntu 24.04.

A centralized authentication server keeps every Linux account, password, SSH public key and sudo rule in one directory, and every server you run asks that directory who’s allowed in instead of trusting its own /etc/passwd. Add a person once and they can log in to the 40 boxes their group is allowed on. Disable them once and they’re locked out of all 40. That’s the whole case for centralized account management: no more pushing useradd with Ansible, no forgotten accounts on the box nobody has touched since 2022, and one place to answer “who has root on the database servers?”

For a mostly-Linux fleet, my pick for that Linux authentication server in 2026 is FreeIPA, which Red Hat ships as Identity Management (IdM). It bundles an LDAP directory, a Kerberos KDC, a certificate authority, optional DNS, host-based access control, sudo rules and SSH key storage behind one CLI and web UI. On the clients, SSSD does the lookups and caches credentials, so a login still works if the IdM server is briefly unreachable.

The 2019 version of this post joined servers to Microsoft Active Directory and extended the AD schema by hand to get sudo rules working. That still works. It’s just no longer the easy road for Linux shops, and the tooling around it has changed: authselect has replaced authconfig on EL9, ipa-client-install wires up SSSD, sudo and SSH for you, and IdM can trust an AD forest when you need both.

Which directory should you use?

OptionBest fitsudo rulesSSH public keysServer packages
FreeIPA / Red Hat IdMLinux-heavy fleets, any sizeBuilt in (ipa sudorule-*)Built in (ipa user-mod --sshpubkey)ipa-server on AlmaLinux 9 / Rocky 9
Active Directory + realm joinWindows already owns identity; a modest number of Linux hostsAD schema extension or per-host sudoers filesNeeds a custom attribute and extra SSSD configWindows Server domain controllers
OpenLDAPA plain LDAP directory for applications, or an existing schema you can’t move offLoad the sudo schema yourselfLoad an SSH key schema yourselfslapd on Ubuntu; EPEL only on EL9

The rest of this guide builds the FreeIPA option. AD join and OpenLDAP get their own sections near the end.

Before you install

FreeIPA is fussy about DNS and time, and most install problems start there. Sort these out first:

  • Pick a domain you’ll keep. FreeIPA’s deployment guide says it should have its own primary DNS domain, not one shared with another Kerberos system such as AD. This guide uses ipa.example.internal with the Kerberos realm IPA.EXAMPLE.INTERNAL. .internal is the top-level domain ICANN reserved for private networks in 2024; avoid .local, which belongs to mDNS.
  • Use a real FQDN. The server’s hostname must be fully qualified (for example idm1.ipa.example.internal) and resolve to its network IP, not a 127.x loopback address.
  • Size it. Red Hat’s minimum for up to 10,000 users and 100 groups is 4 GB of RAM plus 4 GB of swap.
  • Give it its own machine. FreeIPA’s deployment guide recommends keeping other applications off the IdM server, and generally running two or three replicas in each data center.
  • Keep clocks in sync. Kerberos refuses tickets when clocks drift. The installers configure chrony; don’t fight them.

For a small fleet, the floor I’d accept is two IdM servers in different locations, for example one small dedicated server in Chicago and one in Ashburn, replicating to each other. Identity is the one service every other login depends on, so it shouldn’t share a box with your app.

Install the FreeIPA server on AlmaLinux 9 or Rocky Linux 9

On a fresh, updated AlmaLinux 9 or Rocky 9 host, as root:

hostnamectl set-hostname idm1.ipa.example.internal
dnf install -y ipa-server ipa-server-dns
firewall-cmd --permanent --add-service={freeipa-4,dns}
firewall-cmd --reload
ipa-server-install --setup-dns --auto-forwarders --auto-reverse \
    --domain=ipa.example.internal --realm=IPA.EXAMPLE.INTERNAL

The installer asks for a Directory Manager password and an admin password. Store both somewhere better than a sticky note. The freeipa-4 firewalld service opens HTTP, HTTPS, Kerberos, kpasswd, LDAP and LDAPS; it doesn’t include DNS, which is why dns is added next to it. If you already run DNS you trust, drop ipa-server-dns and --setup-dns, and add the DNS records the installer lists to your own zone instead.

Check it works:

kinit admin
ipa user-find admin

For the second server, install the same packages and open the same firewall services, enroll it as a client (next section), then promote it with ipa-replica-install --setup-ca --setup-dns --auto-forwarders. Do it on day one. A single IdM server is a single point of failure for every login you have.

Create a group, a user and a host group

kinit admin
ipa group-add ops --desc="Operations"
ipa user-add alice --first=Alice --last=Example --password
ipa group-add-member ops --users=alice
ipa hostgroup-add web --desc="Web servers"

Users and groups get UID and GID numbers from IdM automatically. Host groups are what you’ll aim access and sudo rules at, so create them by role, not by hostname.

Join clients with ipa-client-install

Clients find the IdM servers through DNS SRV records, so point the client’s resolver at IdM’s DNS (or wherever you published those records) before you start. If you can’t, pass --server=idm1.ipa.example.internal explicitly.

AlmaLinux 9 / Rocky Linux 9

hostnamectl set-hostname web1.ipa.example.internal
dnf install -y ipa-client
ipa-client-install --mkhomedir --domain=ipa.example.internal --principal=admin

The ipa-client package pulls in SSSD as a dependency. With --mkhomedir, the installer also enables oddjobd, so home directories get created at first login.

Ubuntu 24.04

hostnamectl set-hostname web2.ipa.example.internal
apt update
apt install -y freeipa-client
ipa-client-install --mkhomedir --domain=ipa.example.internal --principal=admin

freeipa-client lives in Ubuntu’s universe repository, which Ubuntu labels community maintained, so make sure universe is enabled. On Ubuntu the installer turns on home directory creation through pam-auth-update. apt may also ask for a default Kerberos realm while it installs krb5-user; enter IPA.EXAMPLE.INTERNAL.

On either distro, confirm the join, then add the host to its host group from any enrolled machine with an admin ticket:

id alice
ipa hostgroup-add-member web --hosts=web1.ipa.example.internal --hosts=web2.ipa.example.internal

authselect replaced authconfig on EL9

If your old runbooks call authconfig --enablesssd --update, retire them. Red Hat replaced authconfig with authselect in RHEL 8, and a default AlmaLinux 9 or Rocky 9 install doesn’t have the authconfig command at all. There’s an optional authselect-compat package that fakes it, but Red Hat’s advice is to drop authconfig calls entirely if you join with ipa-client-install or realm join, and convert the rest to authselect. authselect owns /etc/nsswitch.conf and the PAM files in /etc/pam.d/, and it will overwrite hand edits.

You rarely need to touch it. ipa-client-install and realm join both call authselect for you, and Red Hat’s docs recommend against changing the profile they set unless you’ve recorded the current state first. To see what you’ve got:

authselect current

After an IdM join with --mkhomedir, that should show profile sssd with with-mkhomedir and with-sudo enabled. If a host was joined without home directory creation, fix it like this rather than editing PAM:

authselect enable-feature with-mkhomedir
systemctl enable --now oddjobd

Ubuntu doesn’t use authselect. Its equivalent is pam-auth-update, for example pam-auth-update --enable mkhomedir.

Control who can log in where (HBAC)

Out of the box, IdM ships an HBAC rule called allow_all that lets every user into every enrolled host. Fine for a lab. Not fine once contractors exist. Write your own rules, test them, then disable allow_all, in that order. Disable it first and nobody can log in anywhere.

ipa hbacrule-add ops-web
ipa hbacrule-add-user ops-web --groups=ops
ipa hbacrule-add-host ops-web --hostgroups=web
ipa hbacrule-add-service ops-web --hbacsvcs=sshd --hbacsvcs=sudo
ipa hbactest --user=alice --host=web1.ipa.example.internal --service=sshd
ipa hbacrule-disable allow_all

Include sudo as a service in the rule (and sudo-i if your people use sudo -i). Once allow_all is off, SSSD checks HBAC for sudo’s PAM service as well, and a missing entry shows up as a confusing “permission denied” on sudo even when the sudo rule itself is right. Leave the default allow_systemd-user rule enabled; it lets systemd start each user’s session after login.

Manage sudo rules in IdM

This is the part that took hours of AD schema work and ADSI Edit clicking in the original post. In IdM it’s a handful of commands, and ipa-client-install already configured SSSD as a sudo source on every client (unless you passed --no-sudo).

Let the ops group run systemctl as root on the web servers:

ipa sudocmd-add /usr/bin/systemctl
ipa sudorule-add ops-systemctl
ipa sudorule-add-user ops-systemctl --groups=ops
ipa sudorule-add-host ops-systemctl --hostgroups=web
ipa sudorule-add-allow-command ops-systemctl --sudocmds=/usr/bin/systemctl

The “run without a password” setting the old post called a hidden gem is now one documented option:

ipa sudorule-add-option ops-systemctl --sudooption='!authenticate'

Use it sparingly. A passwordless rule on systemctl is effectively root for anyone who can write a unit file.

On the client, log in as alice and run sudo -l. Red Hat notes that changes can take a few minutes to reach clients, because SSSD caches rules and refreshes them on a schedule. If you’re testing and don’t want to wait, run sss_cache -E as root on the client to invalidate the cache.

On Ubuntu, check that /etc/nsswitch.conf has a sudoers: line that includes sss (for example sudoers: files sss). If it’s missing, sudo never asks SSSD and your IdM rules silently do nothing. On EL9, authselect’s with-sudo feature handles that line.

Distribute SSH public keys through IdM

Store each user’s public key on their IdM account:

ipa user-mod alice --sshpubkey="ssh-ed25519 AAAAC3Nza...rest-of-key alice@laptop"

Watch out: --sshpubkey sets the user’s whole key list. To keep two keys, pass the option twice in one command. To remove one, rerun it with only the keys you want to keep.

Nothing else to deploy. ipa-client-install already dropped /etc/ssh/sshd_config.d/04-ipa.conf on each client, which tells sshd to ask SSSD for keys:

AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys
AuthorizedKeysCommandUser nobody

Confirm with sshd -T | grep -i authorizedkeyscommand. Now offboarding is one command, ipa user-disable alice: her password and SSH keys stop working on every enrolled host once SSSD’s cache catches up, and the KDC stops issuing her new Kerberos tickets. No more grepping authorized_keys files across the fleet.

When an Active Directory join makes more sense

If your company already runs AD for Windows desktops and Microsoft 365, and you’ve got a modest number of Linux servers, joining them straight to AD is the simpler call. Your identity team already owns AD; don’t hand them a second directory to babysit.

On AlmaLinux 9 or Rocky 9:

dnf install -y samba-common-tools realmd oddjob oddjob-mkhomedir sssd adcli krb5-workstation
realm discover ad.example.internal
realm join -U Administrator ad.example.internal

On Ubuntu 24.04:

apt install -y sssd-ad sssd-tools realmd adcli
realm discover ad.example.internal
realm join -U Administrator ad.example.internal
pam-auth-update --enable mkhomedir

Then limit logins to the right AD group instead of the whole forest:

realm deny --all
realm permit -g linux-admins@ad.example.internal

Ubuntu’s SSSD-with-AD guide keeps use_fully_qualified_names on, so users log in as alice@ad.example.internal rather than alice. Leave it on unless you’re sure no other domain will ever be trusted into the forest.

Where direct AD join gets painful is policy. Red Hat’s own guidance is that direct integration is the simple way in, but as the share of Linux systems grows you’ll want centralized host-based access control, sudo and SELinux user mapping, which is what IdM with a trust to AD gives you. In that setup AD users keep their AD passwords, and IdM handles the Linux-side policy. It’s set up with the ipa-server-trust-ad package, ipa-adtrust-install and ipa trust-add. My rule of thumb: once you’re editing sudoers files on more than a handful of AD-joined hosts, set up the trust.

OpenLDAP as an alternative

OpenLDAP is still a fine LDAP server. It’s a poor authentication platform to assemble by hand in 2026. You’d be adding Kerberos, a sudo schema, an SSH key schema, a CA and replication yourself, which is roughly the stack FreeIPA already integrates and tests together.

It makes sense when you need a plain directory for applications (mail, a wiki, VPN auth via LDAP bind), when you’re on Debian or Ubuntu servers only and want slapd from the distro, or when you already have an OpenLDAP tree with custom schema you can’t migrate yet. SSSD talks to it fine with id_provider = ldap.

On the Red Hat side, note that RHEL dropped openldap-servers starting with RHEL 8 and points people to 389 Directory Server, the same LDAP server IdM is built on. AlmaLinux 9 and Rocky 9 follow RHEL, so you’d be installing openldap-servers from EPEL. That’s workable, but it’s a hint about where the vendor’s attention is.

When logins fail

  • Clock skew. Run chronyc tracking on client and server. Kerberos rejects tickets when clocks drift too far apart.
  • DNS. dig +short _ldap._tcp.ipa.example.internal SRV should list your IdM servers. If it doesn’t, clients can’t find them.
  • SSSD’s view. sssctl domain-status ipa.example.internal (from the sssd-tools package) shows whether SSSD is online and which server it’s talking to. Logs live in /var/log/sssd/.
  • Stale cache. sss_cache -E invalidates cached users, groups and sudo rules after a change.
  • Access denied with a correct password. Run ipa hbactest for that user, host and service. It’s usually HBAC.