<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Authentication Archives - Linuxcent</title>
	<atom:link href="https://linuxcent.com/tag/authentication/feed/" rel="self" type="application/rss+xml" />
	<link>https://linuxcent.com/tag/authentication/</link>
	<description>Infrastructure security, from the kernel up.</description>
	<lastBuildDate>Sat, 09 May 2026 18:41:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>

<image>
	<url>https://linuxcent.com/wp-content/uploads/2026/04/favicon-512x512-1-150x150.png</url>
	<title>Authentication Archives - Linuxcent</title>
	<link>https://linuxcent.com/tag/authentication/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">211632295</site>	<item>
		<title>Entra ID Linux Login: SSH Authentication with Azure AD Credentials</title>
		<link>https://linuxcent.com/entra-id-linux-login/</link>
					<comments>https://linuxcent.com/entra-id-linux-login/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Sat, 09 May 2026 02:00:00 +0000</pubDate>
				<category><![CDATA[Identity & Authentication]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Azure AD]]></category>
		<category><![CDATA[Cloud Security]]></category>
		<category><![CDATA[Entra ID]]></category>
		<category><![CDATA[Identity Management]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=1805</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 6</span> <span class="rt-label rt-postfix">minutes</span></span>Enable Entra ID SSH login on Linux: aad-auth package, Conditional Access Policies, pam_aad stack, and Entra ID Connect for hybrid on-prem sync.</p>
<p>The post <a href="https://linuxcent.com/entra-id-linux-login/">Entra ID Linux Login: SSH Authentication with Azure AD Credentials</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 6</span> <span class="rt-label rt-postfix">minutes</span></span><style>
pre{position:relative;background:#1e1e1e;color:#d4d4d4;
    padding:16px 16px 16px 20px;border-radius:6px;overflow-x:auto;
    font-family:'JetBrains Mono','Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
    font-size:.88em;line-height:1.6;border-left:4px solid #555}
code{background:#f4f4f4;padding:2px 5px;border-radius:3px;font-size:.9em}
pre code{background:transparent;padding:0;color:inherit}
pre[data-lang="bash"],pre[data-lang="sh"],
pre[data-lang="shell"],pre[data-lang="zsh"]{border-left-color:#4ec9b0}
pre[data-lang="yaml"],pre[data-lang="json"],
pre[data-lang="toml"],pre[data-lang="xml"]{border-left-color:#569cd6}
pre[data-lang="python"],pre[data-lang="go"],pre[data-lang="rust"],
pre[data-lang="java"],pre[data-lang="c"],pre[data-lang="cpp"]{border-left-color:#c586c0}
pre[data-lang="text"],pre[data-lang="output"],
pre[data-lang="console"]{border-left-color:#888}
.lc-copy-btn{position:absolute;top:8px;right:8px;background:#2d2d2d;color:#ccc;
    border:1px solid #444;border-radius:4px;padding:3px 9px;font-size:.75em;
    font-family:system-ui,sans-serif;cursor:pointer;opacity:0;
    transition:opacity .15s,background .15s;line-height:1.6}
pre:hover .lc-copy-btn{opacity:1}
.lc-copy-btn:hover{background:#3a3a3a;color:#fff}
.lc-copy-btn.copied{color:#4ec9b0;border-color:#4ec9b0}
.lc-lang-badge{position:absolute;top:8px;left:20px;font-family:system-ui,sans-serif;
    font-size:.7em;color:#666;text-transform:uppercase;letter-spacing:.04em;
    line-height:1;pointer-events:none;opacity:0;transition:opacity .15s}
pre:hover .lc-lang-badge{opacity:1}
table{border-collapse:collapse;width:100%;margin:16px 0}
th,td{border:1px solid #ddd;padding:10px 14px;text-align:left}
th{background:#f0f0f0;font-weight:600}
tr:nth-child(even){background:#fafafa}
</style>
<p><script>
(function(){
  if(window.__lcCodeEnhanced)return;
  window.__lcCodeEnhanced=true;
  function enhance(){
    document.querySelectorAll('pre').forEach(function(pre){
      var code=pre.querySelector('code');
      var lang='';
      if(code){var m=(code.className||'').match(/language-(\S+)/);if(m)lang=m[1].toLowerCase();}
      if(lang)pre.setAttribute('data-lang',lang);
      if(lang){var badge=document.createElement('span');badge.className='lc-lang-badge';badge.textContent=lang;pre.insertBefore(badge,pre.firstChild);}
      var btn=document.createElement('button');
      btn.className='lc-copy-btn';btn.textContent='Copy';btn.setAttribute('aria-label','Copy code to clipboard');
      pre.appendChild(btn);
      btn.addEventListener('click',function(){
        var text=code?code.innerText:pre.innerText;
        if(navigator.clipboard&&window.isSecureContext){
          navigator.clipboard.writeText(text).then(function(){ok(btn);}).catch(function(){fb(text,btn);});
        }else{fb(text,btn);}
      });
    });
  }
  function ok(btn){btn.textContent='Copied!';btn.classList.add('copied');setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied');},2000);}
  function fb(text,btn){
    try{var ta=document.createElement('textarea');ta.value=text;ta.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);ok(btn);}
    catch(e){btn.textContent='✗ Failed';setTimeout(function(){btn.textContent='Copy';},2000);}
  }
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',enhance);}else{enhance();}
})();
</script></p>
<p><em>The Identity Stack, Episode 12</em><br />
<a href="/identity-providers-explained/">EP11: Identity Providers</a> → <strong>EP12</strong> → <a href="/zero-trust-identity-spiffe-spire/">EP13: Zero Trust Identity</a> → &#8230;</p>
<hr />
<h2 id="tldr">TL;DR</h2>
<ul>
<li>Entra ID (Azure AD) Linux login lets you SSH into a VM using your Azure AD credentials — no local Linux accounts, no SSH keys to distribute</li>
<li>The stack: <code class="" data-line="">aad-auth</code> package + <code class="" data-line="">pam_aad.so</code> + SSSD — Azure authenticates via OIDC device code flow or password, then maps the identity to a local Linux UID</li>
<li>Entra ID is not AD — it&#8217;s OIDC/OAuth2 native, with no LDAP and no Kerberos (unless you add Azure AD DS, a separate managed service)</li>
<li>Conditional Access Policies can gate Linux logins — MFA, device compliance, location restrictions — the same policies as for web apps</li>
<li>Two login modes: interactive (browser-based device code, for non-Azure VMs) and integrated (Azure IMDS-based, for Azure VMs)</li>
<li>Required roles: <code class="" data-line="">Virtual Machine Administrator Login</code> or <code class="" data-line="">Virtual Machine User Login</code> on the VM — IAM, not local sudoers</li>
</ul>
<hr />
<h2 id="the-big-picture-how-entra-id-linux-login-works">The Big Picture: How Entra ID Linux Login Works</h2>
<pre><code class="" data-line="">User: ssh vamshi@vm.corp.azure.com

  sshd on Linux VM
      │
      ▼
  PAM (/etc/pam.d/sshd)
      │
      ├── pam_aad.so (auth)
      │     │
      │     │  OIDC device code flow:
      │     │  &quot;Go to microsoft.com/devicelogin and enter code ABCD-1234&quot;
      │     │  User authenticates in browser with MFA
      │     │  Entra ID issues id_token + access_token
      │     ▼
      │   pam_aad validates token:
      │     • signature (JWKS from Entra ID)
      │     • tenant ID (iss claim)
      │     • VM resource audience (aud claim)
      │     • group membership (groups claim)
      │
      └── pam_mkhomedir (session)
            Creates /home/vamshi@corp.com on first login

  Shell session created
  whoami → vamshi_corp_com (sanitized UPN for Linux username)
</code></pre>
<p>EP11 mapped the IdP landscape. This episode gets specific: Entra ID and Linux. Understanding this matters because Entra ID is increasingly where enterprise identities live, and cloud VMs that SSH into with local accounts are an operational and security liability.</p>
<hr />
<h2 id="entra-id-vs-active-directory-whats-different">Entra ID vs Active Directory: What&#8217;s Different</h2>
<p>This distinction matters before configuring anything.</p>
<table>
<thead>
<tr>
<th></th>
<th>Active Directory (on-prem)</th>
<th>Entra ID (cloud)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Protocol</td>
<td>LDAP + Kerberos</td>
<td>OIDC + OAuth2</td>
</tr>
<tr>
<td>Directory queries</td>
<td><code class="" data-line="">ldapsearch</code></td>
<td>Microsoft Graph API</td>
</tr>
<tr>
<td>Linux join</td>
<td><code class="" data-line="">realm join</code> (adcli + SSSD)</td>
<td><code class="" data-line="">aad-auth</code> package</td>
</tr>
<tr>
<td>Authentication</td>
<td>Kerberos tickets</td>
<td>JWT tokens</td>
</tr>
<tr>
<td>Group policy</td>
<td>GPO via Sysvol</td>
<td>Conditional Access + Intune</td>
</tr>
<tr>
<td>Network requirement</td>
<td>DC reachable on LAN/VPN</td>
<td>HTTPS to login.microsoftonline.com</td>
</tr>
</tbody>
</table>
<p>Entra ID has no LDAP interface and no Kerberos realm. You cannot run <code class="" data-line="">ldapsearch</code> against it. You cannot <code class="" data-line="">kinit</code> to it. The authentication protocol is entirely OIDC/OAuth2 — the same protocol your browser uses to &#8220;Login with Microsoft.&#8221;</p>
<p>If you need LDAP and Kerberos from Azure, that&#8217;s <strong>Azure AD Domain Services</strong> — a separate managed service that Microsoft runs, which does speak LDAP and Kerberos. It&#8217;s not Entra ID; it&#8217;s a managed AD replica in Azure. EP12 covers the Entra ID path — the modern, protocol-native approach.</p>
<hr />
<h2 id="prerequisites">Prerequisites</h2>
<pre><code class="" data-line=""># Azure side:
# 1. The VM&#039;s managed identity must be enabled (System-assigned)
# 2. Two Entra ID roles assigned on the VM resource:
#    - &quot;Virtual Machine Administrator Login&quot; (for sudo access)
#    - &quot;Virtual Machine User Login&quot; (for regular access)
# 3. Conditional Access policies that apply to the VM login scope

# VM side (Ubuntu 20.04+ / RHEL 8+):
# Install the aad-auth package (Microsoft-maintained)
curl -sSL https://packages.microsoft.com/keys/microsoft.asc \
  | gpg --dearmor -o /usr/share/keyrings/microsoft.gpg
echo &quot;deb [signed-by=/usr/share/keyrings/microsoft.gpg] \
  https://packages.microsoft.com/ubuntu/22.04/prod jammy main&quot; \
  &gt; /etc/apt/sources.list.d/microsoft.list
apt-get update &amp;&amp; apt-get install -y aad-auth
</code></pre>
<hr />
<h2 id="configuration">Configuration</h2>
<pre><code class="" data-line=""># Configure the aad-auth package
aad-auth configure \
  --tenant-id 12345678-1234-1234-1234-123456789abc \
  --app-id 87654321-4321-4321-4321-cba987654321

# This writes /etc/aad.conf:
# [aad]
# tenant_id = 12345678-...
# app_id = 87654321-...
# version = 1

# Verify the PAM configuration was updated
grep pam_aad /etc/pam.d/common-auth
# auth [success=1 default=ignore] pam_aad.so
</code></pre>
<p>The <code class="" data-line="">aad-auth</code> package installs <code class="" data-line="">pam_aad.so</code> and configures PAM automatically. It also modifies <code class="" data-line="">/etc/nsswitch.conf</code> to add <code class="" data-line="">aad</code> as a source for <code class="" data-line="">passwd</code> lookups — so <code class="" data-line="">getent passwd vamshi@corp.com</code> works after the first login.</p>
<hr />
<h2 id="the-login-flow">The Login Flow</h2>
<h3 id="on-an-azure-vm-integrated-mode">On an Azure VM (Integrated mode)</h3>
<p>Azure VMs have access to the Instance Metadata Service (IMDS) at <code class="" data-line="">169.254.169.254</code>. <code class="" data-line="">pam_aad</code> uses the VM&#8217;s managed identity to get a token from IMDS, which proves the VM is trusted, then validates the user&#8217;s token against the tenant.</p>
<pre><code class="" data-line=""># User SSHes with username as UPN (user@tenant.onmicrosoft.com or user@corp.com)
ssh vamshi@corp.com@vm.eastus.cloudapp.azure.com

# Or use the short form if the tenant is configured:
ssh vamshi@corp.com@vm.eastus.cloudapp.azure.com
</code></pre>
<p>On first connection, <code class="" data-line="">pam_aad</code> initiates the device code flow:</p>
<pre><code class="" data-line="">To sign in, use a web browser to open https://microsoft.com/devicelogin
and enter the code ABCD-1234 to authenticate.
</code></pre>
<p>The user opens the URL in any browser (on any device), enters the code, and authenticates with their Entra ID credentials + MFA. The SSH session gets a token. Subsequent logins within the token cache TTL skip the device code step.</p>
<h3 id="username-format-on-the-linux-system">Username format on the Linux system</h3>
<p>Entra ID usernames (UPNs) contain <code class="" data-line="">@</code> — not valid in Linux usernames. <code class="" data-line="">aad-auth</code> sanitizes the UPN:</p>
<pre><code class="" data-line="">vamshi@corp.com → vamshi_corp_com    (default)
# or, with shorter_username enabled in /etc/aad.conf:
vamshi@corp.com → vamshi
</code></pre>
<p>The UID is derived from the Azure AD Object ID (a deterministic hash) — stable across logins, same UID on every VM in the tenant.</p>
<hr />
<h2 id="conditional-access-for-linux-logins">Conditional Access for Linux Logins</h2>
<p>Conditional Access Policies in Entra ID apply to Linux VM logins the same way they apply to web app logins.</p>
<pre><code class="" data-line="">Policy: Require MFA for Linux VM Login
  Conditions:
    Cloud apps: &quot;Azure Linux Virtual Machine Sign-In&quot;
    Users: All users (or specific groups)
  Grant:
    Require multi-factor authentication
    Require compliant device (optional)
</code></pre>
<p>With this policy, every SSH login triggers MFA — regardless of whether the client machine supports it. The MFA challenge appears in the device code flow (the browser window the user opens).</p>
<p>You can also enforce:<br />
&#8211; <strong>Location restrictions</strong> — only from corporate IP ranges<br />
&#8211; <strong>Device compliance</strong> — device must be Intune-managed<br />
&#8211; <strong>Sign-in risk</strong> — block logins flagged as risky by Entra ID Identity Protection</p>
<p>This is the operational shift: Linux login security is now managed in the same Conditional Access policy engine as every other Entra ID-protected resource. No more per-machine PAM configuration for MFA.</p>
<hr />
<h2 id="role-based-access-who-can-log-in">Role-Based Access: Who Can Log In</h2>
<p>Access to the VM is controlled by Azure RBAC — not by local Linux groups or sudoers.</p>
<pre><code class="" data-line=""># Grant a user SSH access to the VM
az role assignment create \
  --assignee vamshi@corp.com \
  --role &quot;Virtual Machine User Login&quot; \
  --scope /subscriptions/SUB_ID/resourceGroups/RG/providers/Microsoft.Compute/virtualMachines/VM_NAME

# Grant admin (sudo) access
az role assignment create \
  --assignee vamshi@corp.com \
  --role &quot;Virtual Machine Administrator Login&quot; \
  --scope /subscriptions/SUB_ID/...
</code></pre>
<p><code class="" data-line="">Virtual Machine Administrator Login</code> maps to the <code class="" data-line="">sudo</code> group on the Linux VM. Users with this role get passwordless sudo. Users with <code class="" data-line="">Virtual Machine User Login</code> get a regular shell.</p>
<p>The mapping is enforced by <code class="" data-line="">pam_aad</code> checking the <code class="" data-line="">groups</code> claim in the token against the configured admin group. No <code class="" data-line="">/etc/sudoers.d/</code> files needed.</p>
<hr />
<h2 id="debugging-entra-id-linux-logins">Debugging Entra ID Linux Logins</h2>
<pre><code class="" data-line=""># Check aad-auth service status
systemctl status aad-auth

# View aad-auth logs
journalctl -u aad-auth -f

# Attempt a manual token validation (requires aad-auth debug mode)
aad-auth login --username vamshi@corp.com

# Check the local user cache
getent passwd vamshi_corp_com
# Returns if the user has logged in before

# Clear the local cache (forces re-authentication)
aad-auth clean-cache

# Verify Conditional Access isn&#039;t blocking (check Entra ID Sign-in logs)
# Azure Portal → Entra ID → Sign-in logs → filter by user + app &quot;Azure Linux VM Sign-In&quot;
</code></pre>
<p>The Entra ID Sign-in logs in the Azure Portal show every authentication attempt, the Conditional Access policies that evaluated, which ones passed/failed, and the exact failure reason. This is far more diagnostic than reading PAM logs.</p>
<hr />
<h2 id="entra-id-connect-bringing-on-prem-users-to-entra-id">Entra ID Connect: Bringing On-Prem Users to Entra ID</h2>
<p>For organizations with existing on-prem AD who want to enable Entra ID Linux login:</p>
<pre><code class="" data-line="">On-prem AD users → Entra ID Connect sync → Entra ID
                                                │
                                    Linux VM login (aad-auth)
</code></pre>
<p>Entra ID Connect is a Windows Server application that syncs users from on-prem AD to Entra ID every 30 minutes. Users authenticate against Entra ID (which validates against AD via Password Hash Sync, Pass-Through Authentication, or Federation). The Linux VM doesn&#8217;t know or care — it sees an Entra ID token.</p>
<p>With Password Hash Sync: password hashes (not plaintext) are synced to Entra ID — users authenticate directly in the cloud.<br />
With Pass-Through Authentication: Entra ID forwards authentication requests to an on-prem agent that validates against AD — no password hashes leave the datacenter.<br />
With Federation (AD FS / Entra ID as a relying party): Entra ID delegates authentication to AD FS — the most complex, the most on-prem control.</p>
<hr />
<h2 id="common-misconceptions"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Common Misconceptions</h2>
<p><strong>&#8220;Entra ID = Azure Active Directory = Active Directory.&#8221;</strong> Three different things. Active Directory: on-prem, LDAP+Kerberos. Azure AD (now Entra ID): cloud, OIDC+OAuth2. Azure AD Domain Services: managed AD replica in Azure, LDAP+Kerberos, not Entra ID.</p>
<p><strong>&#8220;You need Azure AD DS to join Linux to Azure.&#8221;</strong> Azure AD DS is the managed AD service. Entra ID Linux login (via aad-auth) is entirely separate and doesn&#8217;t require AD DS. You can authenticate Linux to Entra ID directly via OIDC.</p>
<p><strong>&#8220;The Linux username matches the Entra ID username.&#8221;</strong> The UPN is sanitized (<code class="" data-line="">@</code> → <code class="" data-line="">_</code>) to produce a valid Linux username. The canonical identity is the UPN or the Entra Object ID. Don&#8217;t hardcode the sanitized username in scripts.</p>
<hr />
<h2 id="framework-alignment">Framework Alignment</h2>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Relevance</th>
</tr>
</thead>
<tbody>
<tr>
<td>CISSP Domain 5: Identity and Access Management</td>
<td>Entra ID Linux login centralizes Linux VM access in the same IAM system as all other enterprise resources — one policy engine, one audit log</td>
</tr>
<tr>
<td>CISSP Domain 3: Security Architecture and Engineering</td>
<td>Eliminating per-VM local accounts removes a class of credential management risk — no SSH keys to rotate, no local accounts to audit</td>
</tr>
<tr>
<td>CISSP Domain 1: Security and Risk Management</td>
<td>Conditional Access Policies enforcing MFA on Linux logins reduce the risk of credential-based compromise of cloud VMs</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li>Entra ID Linux login uses OIDC device code flow — no LDAP, no Kerberos, no local Linux accounts</li>
<li><code class="" data-line="">aad-auth</code> package installs <code class="" data-line="">pam_aad.so</code> and handles the full authentication stack: token issuance, validation, user cache, UID mapping</li>
<li>VM access is controlled by Azure RBAC roles (<code class="" data-line="">Virtual Machine Administrator Login</code> / <code class="" data-line="">Virtual Machine User Login</code>) — not by sudoers files</li>
<li>Conditional Access Policies apply to Linux VM logins — MFA, device compliance, and location restrictions use the same engine as every other Entra ID app</li>
<li>Debugging starts in Entra ID Sign-in logs (Azure Portal), not in <code class="" data-line="">/var/log/auth.log</code></li>
</ul>
<hr />
<h2 id="whats-next">What&#8217;s Next</h2>
<p>EP12 showed how Entra ID enables Linux logins in the cloud. EP13 is the series closer: Zero Trust identity — what it means to verify identity continuously, how SPIFFE and SPIRE handle workload (non-human) identity, and where the stack goes from <code class="" data-line="">/etc/passwd</code> in 1970 to a Zero Trust policy engine in 2026.</p>
<p><em>Next: <a href="/zero-trust-identity-spiffe-spire/">Zero Trust Identity: SPIFFE, SPIRE, mTLS, and Continuous Verification</a></em></p>
<p>Get EP13 in your inbox when it publishes → <a href="https://linuxcent.com/subscribe">linuxcent.com/subscribe</a></p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fentra-id-linux-login%2F&amp;linkname=Entra%20ID%20Linux%20Login%3A%20SSH%20Authentication%20with%20Azure%20AD%20Credentials" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fentra-id-linux-login%2F&amp;linkname=Entra%20ID%20Linux%20Login%3A%20SSH%20Authentication%20with%20Azure%20AD%20Credentials" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fentra-id-linux-login%2F&amp;linkname=Entra%20ID%20Linux%20Login%3A%20SSH%20Authentication%20with%20Azure%20AD%20Credentials" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fentra-id-linux-login%2F&amp;linkname=Entra%20ID%20Linux%20Login%3A%20SSH%20Authentication%20with%20Azure%20AD%20Credentials" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fentra-id-linux-login%2F&amp;linkname=Entra%20ID%20Linux%20Login%3A%20SSH%20Authentication%20with%20Azure%20AD%20Credentials" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fentra-id-linux-login%2F&amp;linkname=Entra%20ID%20Linux%20Login%3A%20SSH%20Authentication%20with%20Azure%20AD%20Credentials" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fentra-id-linux-login%2F&amp;linkname=Entra%20ID%20Linux%20Login%3A%20SSH%20Authentication%20with%20Azure%20AD%20Credentials" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fentra-id-linux-login%2F&#038;title=Entra%20ID%20Linux%20Login%3A%20SSH%20Authentication%20with%20Azure%20AD%20Credentials" data-a2a-url="https://linuxcent.com/entra-id-linux-login/" data-a2a-title="Entra ID Linux Login: SSH Authentication with Azure AD Credentials"></a></p><p>The post <a href="https://linuxcent.com/entra-id-linux-login/">Entra ID Linux Login: SSH Authentication with Azure AD Credentials</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/entra-id-linux-login/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1805</post-id>	</item>
		<item>
		<title>SAML vs OIDC vs OAuth2: Which Protocol Handles Which Identity Problem</title>
		<link>https://linuxcent.com/saml-vs-oidc-vs-oauth2/</link>
					<comments>https://linuxcent.com/saml-vs-oidc-vs-oauth2/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Fri, 08 May 2026 05:00:00 +0000</pubDate>
				<category><![CDATA[Identity & Authentication]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Identity Federation]]></category>
		<category><![CDATA[OAuth2]]></category>
		<category><![CDATA[OIDC]]></category>
		<category><![CDATA[SAML]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSO]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=1799</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 6</span> <span class="rt-label rt-postfix">minutes</span></span>SAML vs OIDC vs OAuth2: understand what problem each solves, when to use which, and how a browser SSO flow works end-to-end — from IdP redirect to JWT claim.</p>
<p>The post <a href="https://linuxcent.com/saml-vs-oidc-vs-oauth2/">SAML vs OIDC vs OAuth2: Which Protocol Handles Which Identity Problem</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 6</span> <span class="rt-label rt-postfix">minutes</span></span><style>
pre{position:relative;background:#1e1e1e;color:#d4d4d4;
    padding:16px 16px 16px 20px;border-radius:6px;overflow-x:auto;
    font-family:'JetBrains Mono','Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
    font-size:.88em;line-height:1.6;border-left:4px solid #555}
code{background:#f4f4f4;padding:2px 5px;border-radius:3px;font-size:.9em}
pre code{background:transparent;padding:0;color:inherit}
pre[data-lang="bash"],pre[data-lang="sh"],
pre[data-lang="shell"],pre[data-lang="zsh"]{border-left-color:#4ec9b0}
pre[data-lang="yaml"],pre[data-lang="json"],
pre[data-lang="toml"],pre[data-lang="xml"]{border-left-color:#569cd6}
pre[data-lang="python"],pre[data-lang="go"],pre[data-lang="rust"],
pre[data-lang="java"],pre[data-lang="c"],pre[data-lang="cpp"]{border-left-color:#c586c0}
pre[data-lang="text"],pre[data-lang="output"],
pre[data-lang="console"]{border-left-color:#888}
.lc-copy-btn{position:absolute;top:8px;right:8px;background:#2d2d2d;color:#ccc;
    border:1px solid #444;border-radius:4px;padding:3px 9px;font-size:.75em;
    font-family:system-ui,sans-serif;cursor:pointer;opacity:0;
    transition:opacity .15s,background .15s;line-height:1.6}
pre:hover .lc-copy-btn{opacity:1}
.lc-copy-btn:hover{background:#3a3a3a;color:#fff}
.lc-copy-btn.copied{color:#4ec9b0;border-color:#4ec9b0}
.lc-lang-badge{position:absolute;top:8px;left:20px;font-family:system-ui,sans-serif;
    font-size:.7em;color:#666;text-transform:uppercase;letter-spacing:.04em;
    line-height:1;pointer-events:none;opacity:0;transition:opacity .15s}
pre:hover .lc-lang-badge{opacity:1}
table{border-collapse:collapse;width:100%;margin:16px 0}
th,td{border:1px solid #ddd;padding:10px 14px;text-align:left}
th{background:#f0f0f0;font-weight:600}
tr:nth-child(even){background:#fafafa}
</style>
<p><script>
(function(){
  if(window.__lcCodeEnhanced)return;
  window.__lcCodeEnhanced=true;
  function enhance(){
    document.querySelectorAll('pre').forEach(function(pre){
      var code=pre.querySelector('code');
      var lang='';
      if(code){var m=(code.className||'').match(/language-(\S+)/);if(m)lang=m[1].toLowerCase();}
      if(lang)pre.setAttribute('data-lang',lang);
      if(lang){var badge=document.createElement('span');badge.className='lc-lang-badge';badge.textContent=lang;pre.insertBefore(badge,pre.firstChild);}
      var btn=document.createElement('button');
      btn.className='lc-copy-btn';btn.textContent='Copy';btn.setAttribute('aria-label','Copy code to clipboard');
      pre.appendChild(btn);
      btn.addEventListener('click',function(){
        var text=code?code.innerText:pre.innerText;
        if(navigator.clipboard&&window.isSecureContext){
          navigator.clipboard.writeText(text).then(function(){ok(btn);}).catch(function(){fb(text,btn);});
        }else{fb(text,btn);}
      });
    });
  }
  function ok(btn){btn.textContent='Copied!';btn.classList.add('copied');setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied');},2000);}
  function fb(text,btn){
    try{var ta=document.createElement('textarea');ta.value=text;ta.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);ok(btn);}
    catch(e){btn.textContent='✗ Failed';setTimeout(function(){btn.textContent='Copy';},2000);}
  }
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',enhance);}else{enhance();}
})();
</script></p>
<p><em>The Identity Stack, Episode 10</em><br />
<a href="/active-directory-ldap-kerberos/">EP09: Active Directory</a> → <strong>EP10</strong> → <a href="/identity-providers-explained/">EP11: Identity Providers</a> → &#8230;</p>
<hr />
<h2 id="tldr">TL;DR</h2>
<ul>
<li>SAML 2.0 is a federation protocol for browser-based SSO — an IdP issues a signed XML assertion that a Service Provider trusts; designed for enterprise applications</li>
<li>OAuth2 is an <em>authorization</em> delegation protocol, not authentication — it lets an application act on your behalf without knowing your password; the access token says what, not who</li>
<li>OIDC (OpenID Connect) = OAuth2 + an identity layer — adds the <code class="" data-line="">id_token</code> (a JWT containing who you are) on top of OAuth2&#8217;s <code class="" data-line="">access_token</code> (what you can do)</li>
<li>SAML vs OIDC: SAML is XML, enterprise-native, stateful; OIDC is JSON/JWT, API-native, stateless — new applications almost always use OIDC</li>
<li>The <code class="" data-line="">id_token</code> is a JWT — decode it at jwt.io and read every claim — it tells you exactly what the IdP asserts about the user</li>
<li>The browser SSO flow is three redirects: user → SP → IdP (authenticate) → SP (consume assertion)</li>
</ul>
<hr />
<h2 id="the-problem-ldap-and-kerberos-dont-cross-the-internet">The Problem: LDAP and Kerberos Don&#8217;t Cross the Internet</h2>
<p>EP09 showed how authentication works inside a corporate network. LDAP and Kerberos both assume network proximity to the directory server — firewall-friendly ports don&#8217;t help when the authentication protocol requires a direct connection to the KDC or directory.</p>
<pre><code class="" data-line="">Internal network: works
  Browser → intranet app → LDAP/Kerberos → AD DC (all on 10.0.0.0/8)

Internet: breaks
  Browser → SaaS app (AWS) → LDAP/Kerberos → AD DC (on-prem behind firewall)
  ✗ KDC not reachable across NAT
  ✗ LDAP not exposed to internet (shouldn&#039;t be)
  ✗ Every SaaS app can&#039;t have its own LDAP connection to your DC
</code></pre>
<p>SAML was invented in 2002 to solve this. OIDC in 2014. Both let identity assertions travel over HTTPS — the one protocol that crosses every firewall.</p>
<hr />
<h2 id="saml-20-enterprise-browser-sso">SAML 2.0: Enterprise Browser SSO</h2>
<p>SAML 2.0 has three actors: the User, the Identity Provider (IdP), and the Service Provider (SP).</p>
<pre><code class="" data-line="">1. User visits SP (e.g., Salesforce)
   SP: &quot;I don&#039;t know this user — send them to the IdP&quot;
   ↓  HTTP redirect with SAMLRequest (base64-encoded AuthnRequest)

2. User arrives at IdP (e.g., Okta, AD FS, Entra ID)
   IdP: &quot;Authenticate me&quot; → user enters credentials
   IdP: generates a signed SAML Assertion (XML)
   ↓  HTTP POST to SP&#039;s Assertion Consumer Service (ACS) URL

3. SP receives the SAMLResponse
   SP: verifies the signature using IdP&#039;s public key
   SP: extracts user attributes from the Assertion
   SP: creates a session — user is logged in
</code></pre>
<p>The SAML Assertion is an XML document signed by the IdP. It contains:</p>
<pre><code class="" data-line="">&lt;saml:Assertion&gt;
  &lt;saml:Issuer&gt;https://idp.corp.com&lt;/saml:Issuer&gt;
  &lt;saml:Subject&gt;
    &lt;saml:NameID Format=&quot;urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress&quot;&gt;
      vamshi@corp.com
    &lt;/saml:NameID&gt;
  &lt;/saml:Subject&gt;
  &lt;saml:Conditions
    NotBefore=&quot;2026-04-27T01:00:00Z&quot;
    NotOnOrAfter=&quot;2026-04-27T01:05:00Z&quot;&gt;  ← short-lived: replay protection
  &lt;/saml:Conditions&gt;
  &lt;saml:AttributeStatement&gt;
    &lt;saml:Attribute Name=&quot;email&quot;&gt;
      &lt;saml:AttributeValue&gt;vamshi@corp.com&lt;/saml:AttributeValue&gt;
    &lt;/saml:Attribute&gt;
    &lt;saml:Attribute Name=&quot;groups&quot;&gt;
      &lt;saml:AttributeValue&gt;engineers&lt;/saml:AttributeValue&gt;
      &lt;saml:AttributeValue&gt;sre-team&lt;/saml:AttributeValue&gt;
    &lt;/saml:Attribute&gt;
  &lt;/saml:AttributeStatement&gt;
&lt;/saml:Assertion&gt;
</code></pre>
<p>The SP trusts the assertion because it&#8217;s signed with the IdP&#8217;s private key, and the SP has the IdP&#8217;s public certificate configured. No direct connection between SP and IdP needed during authentication — only the browser carries the assertion.</p>
<p><strong>SP-initiated vs IdP-initiated:</strong><br />
&#8211; SP-initiated: user visits the SP, gets redirected to IdP, authenticates, redirected back — the common flow<br />
&#8211; IdP-initiated: user starts at the IdP (e.g., company portal), clicks an app, IdP sends assertion directly — simpler but no SP-generated RequestID, so the SP can&#8217;t verify the request was expected (a security concern)</p>
<hr />
<h2 id="oauth2-authorization-delegation-not-authentication">OAuth2: Authorization Delegation (Not Authentication)</h2>
<p>This distinction is important and consistently confused: <strong>OAuth2 is for authorization, not authentication.</strong></p>
<p>OAuth2 solves: &#8220;I want to let GitHub Actions post to my Slack without giving GitHub my Slack password.&#8221;</p>
<pre><code class="" data-line="">Resource Owner (you)  → grants permission to →  Client (GitHub Actions)
                                                        │
                                                        │ access_token
                                                        ▼
                                               Resource Server (Slack API)
                                               &quot;this token can post messages&quot;
</code></pre>
<p>The <code class="" data-line="">access_token</code> answers &#8220;what can this client do?&#8221; not &#8220;who is this user?&#8221; A resource server receiving an access token knows the token is valid and what scopes it carries — it does not necessarily know which human authorized it.</p>
<p>The four OAuth2 grant types:</p>
<table>
<thead>
<tr>
<th>Grant</th>
<th>Use case</th>
</tr>
</thead>
<tbody>
<tr>
<td>Authorization Code</td>
<td>Web apps (server-side) — most secure, recommended</td>
</tr>
<tr>
<td>PKCE (+ Auth Code)</td>
<td>Native/SPA apps — Auth Code without client secret</td>
</tr>
<tr>
<td>Client Credentials</td>
<td>Machine-to-machine (no user) — service accounts</td>
</tr>
<tr>
<td>Device Code</td>
<td>Devices without browsers (smart TVs, CLIs)</td>
</tr>
</tbody>
</table>
<p>The Implicit grant (tokens in URL fragment) is deprecated. Don&#8217;t use it.</p>
<hr />
<h2 id="oidc-oauth2-who-you-are">OIDC: OAuth2 + Who You Are</h2>
<p>OpenID Connect adds identity to OAuth2 by adding the <code class="" data-line="">id_token</code> — a JWT that the IdP signs and that contains claims about the authenticated user.</p>
<pre><code class="" data-line="">Authorization Code flow with OIDC:

1. Client redirects user to IdP:
   GET /authorize?
     response_type=code
     &amp;client_id=myapp
     &amp;scope=openid email profile    ← &quot;openid&quot; scope triggers OIDC
     &amp;redirect_uri=https://app.com/callback
     &amp;state=random-nonce

2. IdP authenticates user, returns:
   GET /callback?code=AUTH_CODE&amp;state=random-nonce

3. Client exchanges code for tokens:
   POST /token
   grant_type=authorization_code&amp;code=AUTH_CODE...

4. IdP returns:
   {
     &quot;access_token&quot;: &quot;eyJ...&quot;,    ← what the user authorized
     &quot;id_token&quot;: &quot;eyJ...&quot;,        ← who the user is (JWT)
     &quot;token_type&quot;: &quot;Bearer&quot;,
     &quot;expires_in&quot;: 3600
   }
</code></pre>
<p>The <code class="" data-line="">id_token</code> decoded:</p>
<pre><code class="" data-line="">{
  &quot;iss&quot;: &quot;https://idp.corp.com&quot;,          ← issuer (the IdP)
  &quot;sub&quot;: &quot;user-guid-12345&quot;,               ← subject (stable user identifier)
  &quot;aud&quot;: &quot;myapp&quot;,                          ← audience (your client_id)
  &quot;exp&quot;: 1745730000,                       ← expiry (Unix timestamp)
  &quot;iat&quot;: 1745726400,                       ← issued at
  &quot;email&quot;: &quot;vamshi@corp.com&quot;,
  &quot;name&quot;: &quot;Vamshi Krishna&quot;,
  &quot;groups&quot;: [&quot;engineers&quot;, &quot;sre-team&quot;]     ← custom claims from IdP
}
</code></pre>
<pre><code class="" data-line=""># Decode any JWT at the command line (no verification — for debugging only)
echo &quot;eyJ...&quot; | cut -d. -f2 | base64 -d 2&gt;/dev/null | python3 -m json.tool

# Or: jwt.io — paste the token, read every claim
</code></pre>
<p><strong><code class="" data-line="">sub</code> is the stable user identifier.</strong> Email addresses change. Names change. The <code class="" data-line="">sub</code> claim is the IdP&#8217;s internal identifier for the user — use it as the primary key when storing user data. Never store email as the primary key.</p>
<hr />
<h2 id="saml-vs-oidc-when-to-use-which">SAML vs OIDC: When to Use Which</h2>
<table>
<thead>
<tr>
<th></th>
<th>SAML 2.0</th>
<th>OIDC</th>
</tr>
</thead>
<tbody>
<tr>
<td>Format</td>
<td>XML</td>
<td>JSON / JWT</td>
</tr>
<tr>
<td>Transport</td>
<td>HTTP POST (browser only)</td>
<td>HTTP redirect + JSON API</td>
</tr>
<tr>
<td>Age</td>
<td>2002</td>
<td>2014</td>
</tr>
<tr>
<td>Enterprise adoption</td>
<td>Very high (AD FS, Okta, Entra ID)</td>
<td>Very high (newer apps)</td>
</tr>
<tr>
<td>API-friendly</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Mobile apps</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Complexity</td>
<td>High (XML, schemas, signatures)</td>
<td>Medium (JWT, JSON)</td>
</tr>
<tr>
<td>Single Logout</td>
<td>Specified (rarely works well)</td>
<td>Optional, inconsistent</td>
</tr>
</tbody>
</table>
<p><strong>Use SAML when:</strong> You&#8217;re integrating with an enterprise SaaS that only supports SAML (Salesforce classic, legacy HR systems), or your IdP team mandates it.</p>
<p><strong>Use OIDC when:</strong> You&#8217;re building a new application, integrating with a modern IdP, or need API-based token validation. OIDC is the default for everything new.</p>
<p><strong>Use OAuth2 (Client Credentials) when:</strong> Service-to-service authentication with no user — your CI/CD pipeline authenticating to an API, your microservice calling another microservice.</p>
<hr />
<h2 id="a-complete-browser-sso-flow-oidc">A Complete Browser SSO Flow (OIDC)</h2>
<pre><code class="" data-line="">1. User visits https://app.corp.com (not logged in)
   App: no session → redirect to IdP

2. GET https://idp.corp.com/authorize?
        response_type=code
        &amp;client_id=app-corp
        &amp;scope=openid email
        &amp;redirect_uri=https://app.corp.com/callback
        &amp;state=abc123
        &amp;nonce=xyz789

3. IdP: user is not authenticated → show login form
   User: enters vamshi@corp.com + password
   (or: IdP sees existing session cookie → skip login)

4. IdP: authentication success
   Redirect: GET https://app.corp.com/callback?code=AUTH_CODE&amp;state=abc123

5. App (server-side): validate state=abc123 (CSRF protection)
   POST https://idp.corp.com/token
     grant_type=authorization_code
     &amp;code=AUTH_CODE
     &amp;client_id=app-corp
     &amp;client_secret=SECRET
     &amp;redirect_uri=https://app.corp.com/callback

6. IdP responds:
   { &quot;id_token&quot;: &quot;JWT...&quot;, &quot;access_token&quot;: &quot;JWT...&quot;, &quot;expires_in&quot;: 3600 }

7. App: validate id_token signature (using IdP&#039;s JWKS endpoint)
   App: extract sub, email, groups from id_token
   App: create session for vamshi@corp.com
   App: redirect user to original destination
</code></pre>
<p>Step 7 is where most bugs live. The app must validate: signature (using IdP&#8217;s public keys from <code class="" data-line="">/.well-known/jwks.json</code>), <code class="" data-line="">iss</code> (matches the expected IdP), <code class="" data-line="">aud</code> (matches the client_id), <code class="" data-line="">exp</code> (not expired), and <code class="" data-line="">nonce</code> (matches what was sent in step 2). Skip any of these and you have an authentication bypass.</p>
<hr />
<h2 id="common-misconceptions"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Common Misconceptions</h2>
<p><strong>&#8220;OAuth2 is for login.&#8221;</strong> OAuth2 is for authorization delegation. It can be used as a login mechanism only when OIDC (the <code class="" data-line="">openid</code> scope + <code class="" data-line="">id_token</code>) is added on top. &#8220;Login with Google&#8221; uses OIDC, not bare OAuth2.</p>
<p><strong>&#8220;JWTs are encrypted.&#8221;</strong> By default, JWTs are signed (JWS), not encrypted. The header and payload are base64url-encoded — anyone can decode them. Encryption (JWE) is a separate, less commonly used spec. Never put secrets in a JWT payload assuming it&#8217;s private.</p>
<p><strong>&#8220;SAML Single Logout works reliably.&#8221;</strong> SAML SLO is specified but inconsistently implemented. Many SPs ignore SLO requests or don&#8217;t propagate them correctly. Don&#8217;t depend on SLO for security — session revocation requires additional mechanisms (short-lived tokens, token introspection, session registries).</p>
<hr />
<h2 id="framework-alignment">Framework Alignment</h2>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Relevance</th>
</tr>
</thead>
<tbody>
<tr>
<td>CISSP Domain 5: Identity and Access Management</td>
<td>SAML, OAuth2, and OIDC are the three protocols that enable federated identity and SSO — understanding which does what is foundational to modern IAM design</td>
</tr>
<tr>
<td>CISSP Domain 4: Communications and Network Security</td>
<td>JWT validation (signature, claims, expiry) is a network security control — failing to validate any claim is an authentication bypass vulnerability</td>
</tr>
<tr>
<td>CISSP Domain 3: Security Architecture and Engineering</td>
<td>The choice of SAML vs OIDC is an architectural decision that affects every application integration, mobile support, and API design</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li>SAML 2.0: XML-based browser SSO — three redirects, signed assertion, enterprise legacy apps</li>
<li>OAuth2: authorization delegation — access tokens grant scopes, not identity</li>
<li>OIDC: OAuth2 + <code class="" data-line="">id_token</code> — adds who the user is on top of what they can do</li>
<li><code class="" data-line="">sub</code> is the stable user identifier in OIDC — never use email as a primary key</li>
<li>JWT validation must check: signature, <code class="" data-line="">iss</code>, <code class="" data-line="">aud</code>, <code class="" data-line="">exp</code>, <code class="" data-line="">nonce</code> — missing any is a security bypass</li>
<li>New applications: OIDC. Legacy enterprise SaaS: SAML. Service-to-service: OAuth2 Client Credentials</li>
</ul>
<hr />
<h2 id="whats-next">What&#8217;s Next</h2>
<p>EP10 covered the protocols. EP11 covers the systems that implement them — the identity providers: what Okta, Entra ID, Keycloak, and AD FS actually do, how they federate with each other, and how SCIM handles user provisioning separately from authentication.</p>
<p><em>Next: <a href="/identity-providers-explained/">Identity Providers Explained: On-Prem, Cloud, SCIM, and Federation</a></em></p>
<p>Get EP11 in your inbox when it publishes → <a href="https://linuxcent.com/subscribe">linuxcent.com/subscribe</a></p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fsaml-vs-oidc-vs-oauth2%2F&amp;linkname=SAML%20vs%20OIDC%20vs%20OAuth2%3A%20Which%20Protocol%20Handles%20Which%20Identity%20Problem" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fsaml-vs-oidc-vs-oauth2%2F&amp;linkname=SAML%20vs%20OIDC%20vs%20OAuth2%3A%20Which%20Protocol%20Handles%20Which%20Identity%20Problem" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fsaml-vs-oidc-vs-oauth2%2F&amp;linkname=SAML%20vs%20OIDC%20vs%20OAuth2%3A%20Which%20Protocol%20Handles%20Which%20Identity%20Problem" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fsaml-vs-oidc-vs-oauth2%2F&amp;linkname=SAML%20vs%20OIDC%20vs%20OAuth2%3A%20Which%20Protocol%20Handles%20Which%20Identity%20Problem" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fsaml-vs-oidc-vs-oauth2%2F&amp;linkname=SAML%20vs%20OIDC%20vs%20OAuth2%3A%20Which%20Protocol%20Handles%20Which%20Identity%20Problem" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fsaml-vs-oidc-vs-oauth2%2F&amp;linkname=SAML%20vs%20OIDC%20vs%20OAuth2%3A%20Which%20Protocol%20Handles%20Which%20Identity%20Problem" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fsaml-vs-oidc-vs-oauth2%2F&amp;linkname=SAML%20vs%20OIDC%20vs%20OAuth2%3A%20Which%20Protocol%20Handles%20Which%20Identity%20Problem" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fsaml-vs-oidc-vs-oauth2%2F&#038;title=SAML%20vs%20OIDC%20vs%20OAuth2%3A%20Which%20Protocol%20Handles%20Which%20Identity%20Problem" data-a2a-url="https://linuxcent.com/saml-vs-oidc-vs-oauth2/" data-a2a-title="SAML vs OIDC vs OAuth2: Which Protocol Handles Which Identity Problem"></a></p><p>The post <a href="https://linuxcent.com/saml-vs-oidc-vs-oauth2/">SAML vs OIDC vs OAuth2: Which Protocol Handles Which Identity Problem</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/saml-vs-oidc-vs-oauth2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1799</post-id>	</item>
		<item>
		<title>How Kerberos Works: Tickets, KDC, and Why Enterprises Use It With LDAP</title>
		<link>https://linuxcent.com/how-kerberos-works/</link>
					<comments>https://linuxcent.com/how-kerberos-works/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Mon, 04 May 2026 05:00:00 +0000</pubDate>
				<category><![CDATA[Identity & Authentication]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Identity Management]]></category>
		<category><![CDATA[Kerberos]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=1784</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 7</span> <span class="rt-label rt-postfix">minutes</span></span>How Kerberos works: the KDC, TGT flow, ticket-granting service, and why enterprises pair it with LDAP — explained with kinit, klist, and wire-level detail.</p>
<p>The post <a href="https://linuxcent.com/how-kerberos-works/">How Kerberos Works: Tickets, KDC, and Why Enterprises Use It With LDAP</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 7</span> <span class="rt-label rt-postfix">minutes</span></span><style>
pre{position:relative;background:#1e1e1e;color:#d4d4d4;
    padding:16px 16px 16px 20px;border-radius:6px;overflow-x:auto;
    font-family:'JetBrains Mono','Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
    font-size:.88em;line-height:1.6;border-left:4px solid #555}
code{background:#f4f4f4;padding:2px 5px;border-radius:3px;font-size:.9em}
pre code{background:transparent;padding:0;color:inherit}
pre[data-lang="bash"],pre[data-lang="sh"],
pre[data-lang="shell"],pre[data-lang="zsh"]{border-left-color:#4ec9b0}
pre[data-lang="yaml"],pre[data-lang="json"],
pre[data-lang="toml"],pre[data-lang="xml"]{border-left-color:#569cd6}
pre[data-lang="python"],pre[data-lang="go"],pre[data-lang="rust"],
pre[data-lang="java"],pre[data-lang="c"],pre[data-lang="cpp"]{border-left-color:#c586c0}
pre[data-lang="text"],pre[data-lang="output"],
pre[data-lang="console"]{border-left-color:#888}
.lc-copy-btn{position:absolute;top:8px;right:8px;background:#2d2d2d;color:#ccc;
    border:1px solid #444;border-radius:4px;padding:3px 9px;font-size:.75em;
    font-family:system-ui,sans-serif;cursor:pointer;opacity:0;
    transition:opacity .15s,background .15s;line-height:1.6}
pre:hover .lc-copy-btn{opacity:1}
.lc-copy-btn:hover{background:#3a3a3a;color:#fff}
.lc-copy-btn.copied{color:#4ec9b0;border-color:#4ec9b0}
.lc-lang-badge{position:absolute;top:8px;left:20px;font-family:system-ui,sans-serif;
    font-size:.7em;color:#666;text-transform:uppercase;letter-spacing:.04em;
    line-height:1;pointer-events:none;opacity:0;transition:opacity .15s}
pre:hover .lc-lang-badge{opacity:1}
table{border-collapse:collapse;width:100%;margin:16px 0}
th,td{border:1px solid #ddd;padding:10px 14px;text-align:left}
th{background:#f0f0f0;font-weight:600}
tr:nth-child(even){background:#fafafa}
</style>
<p><script>
(function(){
  if(window.__lcCodeEnhanced)return;
  window.__lcCodeEnhanced=true;
  function enhance(){
    document.querySelectorAll('pre').forEach(function(pre){
      var code=pre.querySelector('code');
      var lang='';
      if(code){var m=(code.className||'').match(/language-(\S+)/);if(m)lang=m[1].toLowerCase();}
      if(lang)pre.setAttribute('data-lang',lang);
      if(lang){var badge=document.createElement('span');badge.className='lc-lang-badge';badge.textContent=lang;pre.insertBefore(badge,pre.firstChild);}
      var btn=document.createElement('button');
      btn.className='lc-copy-btn';btn.textContent='Copy';btn.setAttribute('aria-label','Copy code to clipboard');
      pre.appendChild(btn);
      btn.addEventListener('click',function(){
        var text=code?code.innerText:pre.innerText;
        if(navigator.clipboard&&window.isSecureContext){
          navigator.clipboard.writeText(text).then(function(){ok(btn);}).catch(function(){fb(text,btn);});
        }else{fb(text,btn);}
      });
    });
  }
  function ok(btn){btn.textContent='Copied!';btn.classList.add('copied');setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied');},2000);}
  function fb(text,btn){
    try{var ta=document.createElement('textarea');ta.value=text;ta.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);ok(btn);}
    catch(e){btn.textContent='✗ Failed';setTimeout(function(){btn.textContent='Copy';},2000);}
  }
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',enhance);}else{enhance();}
})();
</script></p>
<p><em>The Identity Stack, Episode 5</em><br />
<a href="/what-is-ldap/">EP01</a> → <a href="/ldap-internals-directory-structure/">EP02</a> → <a href="/ldap-authentication-linux-pam-nss/">EP03</a> → <a href="/sssd-linux-authentication/">EP04: SSSD</a> → <strong>EP05</strong> → <a href="/openldap-setup-replication/">EP06: OpenLDAP</a> → &#8230;</p>
<hr />
<h2 id="tldr">TL;DR</h2>
<ul>
<li>Kerberos is a network authentication protocol — it proves identity without sending passwords over the network, using time-limited cryptographic tickets</li>
<li>Three actors: the client, the KDC (Key Distribution Center), and the service — the KDC issues tickets; clients use tickets to authenticate to services</li>
<li>The ticket flow: AS-REQ (get a TGT) → TGS-REQ (exchange TGT for a service ticket) → AP-REQ (present service ticket to the target service)</li>
<li>A TGT (Ticket-Granting Ticket) is a session credential — it lets you request service tickets without re-entering your password for the lifetime of the ticket (default 10 hours)</li>
<li>LDAP + Kerberos together: LDAP stores identity (who you are), Kerberos authenticates it (proves you are who you say you are) — Active Directory is exactly this combination</li>
<li><code class="" data-line="">kinit</code>, <code class="" data-line="">klist</code>, <code class="" data-line="">kdestroy</code> are the hands-on tools — run them and read the ticket output</li>
</ul>
<hr />
<h2 id="the-big-picture-three-actors-three-steps">The Big Picture: Three Actors, Three Steps</h2>
<pre><code class="" data-line="">         1. AS-REQ / AS-REP
Client ◄────────────────────► AS (Authentication Server)
  │                                     │
  │    (part of KDC)                    │
  │                                     ▼
  │         2. TGS-REQ / TGS-REP   TGS (Ticket-Granting Server)
  ├───────────────────────────────────►│
  │         (part of KDC)              │
  │                                    │
  │    3. AP-REQ / AP-REP              │
  └─────────────────────────────► Service (SSH, LDAP, NFS, HTTP...)

KDC = AS + TGS (usually the same process, same machine)
</code></pre>
<p>EP04 mentioned Kerberos tickets and clock skew requirements without explaining the protocol. This episode explains why Kerberos was invented, what a ticket actually is, and how the three-step flow works — so that when SSSD says &#8220;KDC unreachable&#8221; or <code class="" data-line="">kinit</code> fails with &#8220;pre-authentication required,&#8221; you know exactly what&#8217;s happening.</p>
<hr />
<h2 id="the-problem-kerberos-was-built-to-solve">The Problem Kerberos Was Built to Solve</h2>
<p>MIT&#8217;s Project Athena started in 1983 — a campus-wide computing initiative giving students access to thousands of workstations. The problem: how do you authenticate a student at workstation 847 to a file server across campus without sending their password over the network?</p>
<p>In 1988, Steve Miller and Clifford Neuman published Kerberos version 4. The core insight: a trusted third party (the KDC) can issue cryptographic proof that a user has authenticated, and that proof can be presented to any service on the network without the service ever seeing the user&#8217;s password.</p>
<p>The password never leaves the client machine after the initial authentication. Every subsequent authentication — to a different service, to the same service again — uses a ticket. The KDC knows both the client and the service. The client and service only need to trust the KDC.</p>
<hr />
<h2 id="keys-tickets-and-sessions">Keys, Tickets, and Sessions</h2>
<p>Before the protocol, the primitives:</p>
<p><strong>Long-term keys</strong> — derived from passwords. When you set a password in Kerberos, it&#8217;s hashed into a key stored in the KDC database (in the <code class="" data-line="">krbtgt</code> account on AD, in <code class="" data-line="">/var/lib/krb5kdc/principal</code> on MIT Kerberos). The client also derives this key from the password at authentication time. Neither ever sends the raw password.</p>
<p><strong>Session keys</strong> — temporary symmetric keys created by the KDC for a specific session. They&#8217;re valid for the ticket&#8217;s lifetime. After the ticket expires, the session key is useless.</p>
<p><strong>Tickets</strong> — encrypted blobs issued by the KDC. A ticket contains the session key, the client identity, the expiry time, and optional flags. It&#8217;s encrypted with the target service&#8217;s long-term key — only the service can decrypt it. The client carries the ticket but can&#8217;t read the contents.</p>
<hr />
<h2 id="the-three-step-flow">The Three-Step Flow</h2>
<h3 id="step-1-as-req-as-rep-getting-a-tgt">Step 1: AS-REQ / AS-REP — Getting a TGT</h3>
<pre><code class="" data-line="">Client                        KDC (AS component)
  │                                │
  │── AS-REQ ──────────────────────►
  │   {username, timestamp}         │
  │   (timestamp encrypted with     │
  │    client&#039;s long-term key)       │
  │                                 │
  │   KDC verifies: decrypts        │
  │   timestamp with stored key.    │
  │   If valid → issues TGT         │
  │                                 │
  ◄── AS-REP ──────────────────────│
      {session_key_enc_with_client, │
       TGT_enc_with_krbtgt_key}     │
</code></pre>
<p>The client decrypts the session key using its long-term key (derived from the password). The TGT is encrypted with the KDC&#8217;s own key (<code class="" data-line="">krbtgt</code>) — the client can&#8217;t read it, but carries it.</p>
<p>This is the step that requires the password. After this, the TGT is what the client uses for everything else.</p>
<h3 id="step-2-tgs-req-tgs-rep-getting-a-service-ticket">Step 2: TGS-REQ / TGS-REP — Getting a Service Ticket</h3>
<pre><code class="" data-line="">Client                        KDC (TGS component)
  │                                │
  │── TGS-REQ ─────────────────────►
  │   {TGT, authenticator,         │
  │    target_service_name}        │
  │   (authenticator encrypted      │
  │    with TGT session key)        │
  │                                 │
  │   KDC: decrypts TGT,           │
  │   verifies authenticator,       │
  │   issues service ticket         │
  │                                 │
  ◄── TGS-REP ────────────────────│
      {service_session_key_enc,    │
       service_ticket_enc_with_    │
       service_long_term_key}      │
</code></pre>
<p>No password involved. The client proves its identity by presenting the TGT (which only the KDC can issue) and an authenticator (a timestamp encrypted with the TGT&#8217;s session key, proving the client holds the session key without revealing it).</p>
<h3 id="step-3-ap-req-ap-rep-authenticating-to-the-service">Step 3: AP-REQ / AP-REP — Authenticating to the Service</h3>
<pre><code class="" data-line="">Client                        Service (sshd, LDAP, NFS...)
  │                                │
  │── AP-REQ ──────────────────────►
  │   {service_ticket,             │
  │    authenticator_enc_with_      │
  │    service_session_key}        │
  │                                 │
  │   Service: decrypts ticket      │
  │   with its long-term key,       │
  │   verifies authenticator        │
  │                                 │
  ◄── AP-REP (optional) ───────────│
      {mutual authentication}       │
</code></pre>
<p>The service decrypts the ticket using its own key. It extracts the client identity and session key. It verifies the authenticator. No communication with the KDC required — the service trusts what the KDC signed.</p>
<hr />
<h2 id="why-clock-skew-matters">Why Clock Skew Matters</h2>
<p>Every Kerberos authenticator contains a timestamp. The service rejects authenticators older than 5 minutes (by default) — this prevents replay attacks where an attacker captures an authenticator and replays it later.</p>
<p>This is why clock skew over 5 minutes breaks Kerberos authentication entirely. If your machine&#8217;s clock drifts 6 minutes from the KDC, every authenticator you generate is rejected as too old or too far in the future. No tickets. No AD logins. No SSSD authentication.</p>
<pre><code class="" data-line=""># Check time sync status
timedatectl status
chronyc tracking        # if using chrony
ntpq -p                 # if using ntpd

# If clock is off: force a sync
chronyc makestep        # immediate step correction (chrony)
</code></pre>
<hr />
<h2 id="hands-on-kinit-klist-kdestroy">Hands-On: kinit, klist, kdestroy</h2>
<pre><code class="" data-line=""># Get a TGT (will prompt for password)
kinit vamshi@CORP.COM

# Show current tickets
klist
# Credentials cache: FILE:/tmp/krb5cc_1001
# Principal: vamshi@CORP.COM
#
# Valid starting     Expires            Service principal
# 04/27/26 01:00:00  04/27/26 11:00:00  krbtgt/CORP.COM@CORP.COM
#   renew until 05/04/26 01:00:00

# Show encryption types used (the -e flag)
klist -e
# 04/27/26 01:00:00  04/27/26 11:00:00  krbtgt/CORP.COM@CORP.COM
#         Etype: aes256-cts-hmac-sha1-96, aes256-cts-hmac-sha1-96

# Get a service ticket for a specific service
kvno host/server.corp.com@CORP.COM
# host/server.corp.com@CORP.COM: kvno = 3

# Show all tickets including service tickets
klist -f
# Flags: F=forwardable, f=forwarded, P=proxiable, p=proxy, D=postdated,
#        d=postdated, R=renewable, I=initial, i=invalid, H=hardware auth

# Destroy all tickets
kdestroy
</code></pre>
<p>The <code class="" data-line="">Valid starting</code> and <code class="" data-line="">Expires</code> fields are the ticket lifetime. After expiry, you need to re-authenticate (or renew the ticket if it&#8217;s within the <code class="" data-line="">renew until</code> window). The <code class="" data-line="">renew until</code> date is when even renewal stops working.</p>
<hr />
<h2 id="etckrb5conf">/etc/krb5.conf</h2>
<pre><code class="" data-line="">[libdefaults]
    default_realm = CORP.COM
    dns_lookup_realm = false
    dns_lookup_kdc = true         # find KDCs via DNS SRV records
    ticket_lifetime = 10h
    renew_lifetime = 7d
    forwardable = true            # tickets can be forwarded to remote hosts (needed for SSH forwarding)
    rdns = false

[realms]
    CORP.COM = {
        kdc = dc01.corp.com
        kdc = dc02.corp.com       # failover KDC
        admin_server = dc01.corp.com
    }

[domain_realm]
    .corp.com = CORP.COM
    corp.com = CORP.COM
</code></pre>
<p>With <code class="" data-line="">dns_lookup_kdc = true</code>, Kerberos finds KDCs by querying DNS SRV records (<code class="" data-line="">_kerberos._tcp.corp.com</code>). AD sets these up automatically. On MIT Kerberos, you add them manually. DNS-based discovery is the recommended approach for AD environments — it picks up new DCs automatically.</p>
<hr />
<h2 id="kerberos-ldap-why-enterprises-run-both">Kerberos + LDAP: Why Enterprises Run Both</h2>
<p>LDAP and Kerberos solve different problems and are almost always deployed together:</p>
<pre><code class="" data-line="">LDAP answers:  &quot;Who is vamshi? What groups is he in? What&#039;s his home directory?&quot;
Kerberos answers: &quot;Is this really vamshi? Prove it without sending a password.&quot;
</code></pre>
<p>Active Directory is exactly this combination — the directory is LDAP-based, the authentication is Kerberos. When a Linux machine joins an AD domain via <code class="" data-line="">realm join</code> or <code class="" data-line="">adcli</code>, it gets:<br />
&#8211; LDAP access to the AD directory (for NSS: user and group lookups)<br />
&#8211; A Kerberos principal registered in AD (for PAM: ticket-based authentication)<br />
&#8211; A machine account (the machine&#8217;s identity in the directory)</p>
<p>When you SSH into an AD-joined Linux machine:<br />
1. SSSD issues a Kerberos AS-REQ for the user&#8217;s TGT<br />
2. SSSD uses the TGT to get a service ticket for the Linux machine&#8217;s PAM service<br />
3. Authentication is verified via the service ticket — no LDAP Bind with a password<br />
4. SSSD does an LDAP Search to get POSIX attributes (UID, GID, home dir)</p>
<p>Password-based LDAP Bind is the fallback when Kerberos isn&#8217;t available. Kerberos is the default on AD-joined systems — and it&#8217;s more secure because the password never leaves the client.</p>
<hr />
<h2 id="common-misconceptions"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Common Misconceptions</h2>
<p><strong>&#8220;Kerberos sends your password to the KDC.&#8221;</strong> It doesn&#8217;t. The client derives a key from the password locally and uses that key to encrypt a timestamp (the pre-authentication data). The KDC verifies the timestamp using the stored key. The raw password never travels.</p>
<p><strong>&#8220;Kerberos is an authorization protocol.&#8221;</strong> Kerberos authenticates — it proves who you are. Authorization (what you can do) is a separate decision, usually handled by ACLs on the service or directory group membership.</p>
<p><strong>&#8220;Once you have a TGT, you&#8217;re authenticated to everything.&#8221;</strong> A TGT only proves your identity to the KDC. Each service requires a separate service ticket. The TGT is what lets you get those service tickets without re-entering your password.</p>
<p><strong>&#8220;Kerberos requires AD.&#8221;</strong> MIT Kerberos 5 is a standalone implementation. FreeIPA (EP08) runs MIT Kerberos. Heimdal is another implementation. AD uses a Microsoft-extended version of Kerberos 5, but the core protocol is the same RFC.</p>
<hr />
<h2 id="framework-alignment">Framework Alignment</h2>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Relevance</th>
</tr>
</thead>
<tbody>
<tr>
<td>CISSP Domain 5: Identity and Access Management</td>
<td>Kerberos is the de facto enterprise authentication protocol — SSO, delegation, and service account authentication all depend on it</td>
</tr>
<tr>
<td>CISSP Domain 4: Communications and Network Security</td>
<td>Kerberos prevents credential sniffing and replay attacks — two of the core network authentication threat categories</td>
</tr>
<tr>
<td>CISSP Domain 3: Security Architecture and Engineering</td>
<td>The KDC is a critical single point of trust — its availability, key management, and account (<code class="" data-line="">krbtgt</code>) rotation are architectural security decisions</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li>Kerberos is a ticket-based protocol — the password is used once to get a TGT; from then on, tickets prove identity without the password</li>
<li>The three-step flow: get a TGT from the AS, exchange it for a service ticket at the TGS, present the service ticket to the target service</li>
<li>Clock skew over 5 minutes breaks Kerberos — time synchronization is a hard dependency</li>
<li>LDAP stores identity; Kerberos authenticates it — Active Directory is exactly this combination, and so is FreeIPA</li>
<li><code class="" data-line="">klist -e</code> shows the encryption types in use — <code class="" data-line="">aes256-cts-hmac-sha1-96</code> is what you want to see; <code class="" data-line="">arcfour-hmac</code> (RC4) is legacy and should be disabled</li>
</ul>
<hr />
<h2 id="whats-next">What&#8217;s Next</h2>
<p>EP05 covered Kerberos as a protocol. EP06 goes hands-on: building a real LDAP directory with OpenLDAP, configuring replication, and understanding how the server-side components — <code class="" data-line="">slapd</code>, the MDB backend, SyncRepl — fit together.</p>
<p><em>Next: <a href="/openldap-setup-replication/">OpenLDAP Setup and Replication: Running Your Own Directory</a></em></p>
<p>Get EP06 in your inbox when it publishes → <a href="https://linuxcent.com/subscribe">linuxcent.com/subscribe</a></p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-kerberos-works%2F&amp;linkname=How%20Kerberos%20Works%3A%20Tickets%2C%20KDC%2C%20and%20Why%20Enterprises%20Use%20It%20With%20LDAP" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-kerberos-works%2F&amp;linkname=How%20Kerberos%20Works%3A%20Tickets%2C%20KDC%2C%20and%20Why%20Enterprises%20Use%20It%20With%20LDAP" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-kerberos-works%2F&amp;linkname=How%20Kerberos%20Works%3A%20Tickets%2C%20KDC%2C%20and%20Why%20Enterprises%20Use%20It%20With%20LDAP" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-kerberos-works%2F&amp;linkname=How%20Kerberos%20Works%3A%20Tickets%2C%20KDC%2C%20and%20Why%20Enterprises%20Use%20It%20With%20LDAP" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-kerberos-works%2F&amp;linkname=How%20Kerberos%20Works%3A%20Tickets%2C%20KDC%2C%20and%20Why%20Enterprises%20Use%20It%20With%20LDAP" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-kerberos-works%2F&amp;linkname=How%20Kerberos%20Works%3A%20Tickets%2C%20KDC%2C%20and%20Why%20Enterprises%20Use%20It%20With%20LDAP" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-kerberos-works%2F&amp;linkname=How%20Kerberos%20Works%3A%20Tickets%2C%20KDC%2C%20and%20Why%20Enterprises%20Use%20It%20With%20LDAP" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fhow-kerberos-works%2F&#038;title=How%20Kerberos%20Works%3A%20Tickets%2C%20KDC%2C%20and%20Why%20Enterprises%20Use%20It%20With%20LDAP" data-a2a-url="https://linuxcent.com/how-kerberos-works/" data-a2a-title="How Kerberos Works: Tickets, KDC, and Why Enterprises Use It With LDAP"></a></p><p>The post <a href="https://linuxcent.com/how-kerberos-works/">How Kerberos Works: Tickets, KDC, and Why Enterprises Use It With LDAP</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/how-kerberos-works/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1784</post-id>	</item>
		<item>
		<title>SSSD: The Caching Daemon That Powers Every Enterprise Linux Login</title>
		<link>https://linuxcent.com/sssd-linux-authentication/</link>
					<comments>https://linuxcent.com/sssd-linux-authentication/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Mon, 27 Apr 2026 05:00:00 +0000</pubDate>
				<category><![CDATA[Identity & Authentication]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux-security]]></category>
		<category><![CDATA[PAM]]></category>
		<category><![CDATA[SSSD]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=1781</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 7</span> <span class="rt-label rt-postfix">minutes</span></span>SSSD is the daemon behind every enterprise Linux login — offline caching, PAM integration, multi-domain support. Here's how it works and how to debug it.</p>
<p>The post <a href="https://linuxcent.com/sssd-linux-authentication/">SSSD: The Caching Daemon That Powers Every Enterprise Linux Login</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 7</span> <span class="rt-label rt-postfix">minutes</span></span><style>
pre{position:relative;background:#1e1e1e;color:#d4d4d4;
    padding:16px 16px 16px 20px;border-radius:6px;overflow-x:auto;
    font-family:'JetBrains Mono','Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
    font-size:.88em;line-height:1.6;border-left:4px solid #555}
code{background:#f4f4f4;padding:2px 5px;border-radius:3px;font-size:.9em}
pre code{background:transparent;padding:0;color:inherit}
pre[data-lang="bash"],pre[data-lang="sh"],
pre[data-lang="shell"],pre[data-lang="zsh"]{border-left-color:#4ec9b0}
pre[data-lang="yaml"],pre[data-lang="json"],
pre[data-lang="toml"],pre[data-lang="xml"]{border-left-color:#569cd6}
pre[data-lang="python"],pre[data-lang="go"],pre[data-lang="rust"],
pre[data-lang="java"],pre[data-lang="c"],pre[data-lang="cpp"]{border-left-color:#c586c0}
pre[data-lang="text"],pre[data-lang="output"],
pre[data-lang="console"]{border-left-color:#888}
.lc-copy-btn{position:absolute;top:8px;right:8px;background:#2d2d2d;color:#ccc;
    border:1px solid #444;border-radius:4px;padding:3px 9px;font-size:.75em;
    font-family:system-ui,sans-serif;cursor:pointer;opacity:0;
    transition:opacity .15s,background .15s;line-height:1.6}
pre:hover .lc-copy-btn{opacity:1}
.lc-copy-btn:hover{background:#3a3a3a;color:#fff}
.lc-copy-btn.copied{color:#4ec9b0;border-color:#4ec9b0}
.lc-lang-badge{position:absolute;top:8px;left:20px;font-family:system-ui,sans-serif;
    font-size:.7em;color:#666;text-transform:uppercase;letter-spacing:.04em;
    line-height:1;pointer-events:none;opacity:0;transition:opacity .15s}
pre:hover .lc-lang-badge{opacity:1}
table{border-collapse:collapse;width:100%;margin:16px 0}
th,td{border:1px solid #ddd;padding:10px 14px;text-align:left}
th{background:#f0f0f0;font-weight:600}
tr:nth-child(even){background:#fafafa}
</style>
<p><script>
(function(){
  if(window.__lcCodeEnhanced)return;
  window.__lcCodeEnhanced=true;
  function enhance(){
    document.querySelectorAll('pre').forEach(function(pre){
      var code=pre.querySelector('code');
      var lang='';
      if(code){var m=(code.className||'').match(/language-(\S+)/);if(m)lang=m[1].toLowerCase();}
      if(lang)pre.setAttribute('data-lang',lang);
      if(lang){var badge=document.createElement('span');badge.className='lc-lang-badge';badge.textContent=lang;pre.insertBefore(badge,pre.firstChild);}
      var btn=document.createElement('button');
      btn.className='lc-copy-btn';btn.textContent='Copy';btn.setAttribute('aria-label','Copy code to clipboard');
      pre.appendChild(btn);
      btn.addEventListener('click',function(){
        var text=code?code.innerText:pre.innerText;
        if(navigator.clipboard&&window.isSecureContext){
          navigator.clipboard.writeText(text).then(function(){ok(btn);}).catch(function(){fb(text,btn);});
        }else{fb(text,btn);}
      });
    });
  }
  function ok(btn){btn.textContent='Copied!';btn.classList.add('copied');setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied');},2000);}
  function fb(text,btn){
    try{var ta=document.createElement('textarea');ta.value=text;ta.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);ok(btn);}
    catch(e){btn.textContent='✗ Failed';setTimeout(function(){btn.textContent='Copy';},2000);}
  }
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',enhance);}else{enhance();}
})();
</script></p>
<p><em>The Identity Stack, Episode 4</em><br />
<a href="/what-is-ldap/">EP01: What Is LDAP</a> → <a href="/ldap-internals-directory-structure/">EP02: LDAP Internals</a> → <a href="/ldap-authentication-linux-pam-nss/">EP03: LDAP Auth on Linux</a> → <strong>EP04</strong> → <a href="/how-kerberos-works-tickets-kdc/">EP05: Kerberos</a> → &#8230;</p>
<hr />
<h2 id="tldr">TL;DR</h2>
<ul>
<li>SSSD (System Security Services Daemon) is the caching and brokering layer between Linux and directory services — it handles LDAP, Kerberos, and AD so PAM and NSS don&#8217;t have to</li>
<li>Architecture: three tiers — responders (answer PAM/NSS queries), providers (talk to AD/LDAP/Kerberos), and a shared cache (LDB database on disk)</li>
<li>Credential caching means offline logins work — a user who authenticated yesterday can log in today even if the domain controller is unreachable</li>
<li>Key config: <code class="" data-line="">sssd.conf</code> — the <code class="" data-line="">[domain]</code> section is where almost all tuning happens</li>
<li>Debugging toolkit: <code class="" data-line="">sssctl</code>, <code class="" data-line="">sss_cache</code>, <code class="" data-line="">id</code>, <code class="" data-line="">getent</code>, <code class="" data-line="">journalctl -u sssd</code></li>
<li>The most common failure modes are: SSSD not running, stale cache, misconfigured <code class="" data-line="">ldap_search_base</code>, and clock skew breaking Kerberos</li>
</ul>
<hr />
<h2 id="the-big-picture-sssd-as-the-identity-broker">The Big Picture: SSSD as the Identity Broker</h2>
<pre><code class="" data-line="">PAM (pam_sss)         NSS (sss module)
      │                      │
      └──────────┬───────────┘
                 ▼
          SSSD Responders
          ┌────────────────────────────────────┐
          │  PAM responder   NSS responder      │
          │  (auth, account, (passwd, group,    │
          │   session)        shadow lookups)   │
          └────────────┬───────────────────────┘
                       │  shared cache (LDB)
                       ▼
          SSSD Providers
          ┌────────────────────────────────────┐
          │  identity provider  auth provider   │
          │  (user/group attrs) (credentials)   │
          └────────────┬───────────────────────┘
                       │
          ┌────────────┼────────────┐
          ▼            ▼            ▼
       LDAP          Kerberos    Local files
    (AD / OpenLDAP)  (KDC / AD)
</code></pre>
<p>EP03 showed that SSSD sits between PAM and LDAP. This episode goes inside it — the architecture, the config, and how to tell exactly what it&#8217;s doing on any given login attempt.</p>
<hr />
<h2 id="why-sssd-exists">Why SSSD Exists</h2>
<p>The problem before SSSD: <code class="" data-line="">nss_ldap</code> and <code class="" data-line="">pam_ldap</code> made direct LDAP connections for every query. No caching, no connection pooling, no failover, no offline support. On a system that makes dozens of <code class="" data-line="">getpwuid()</code> calls per second (every <code class="" data-line="">ls -l</code>, every process spawn), this meant dozens of LDAP roundtrips per second hitting the domain controller.</p>
<p>SSSD solved this with a single daemon that:<br />
&#8211; Maintains a persistent connection pool to the directory<br />
&#8211; Caches identity and credential data in an LDB (LDAP-like) database on disk<br />
&#8211; Handles failover across multiple directory servers<br />
&#8211; Satisfies PAM and NSS queries from cache when the directory is unreachable</p>
<p>The credential cache is the key insight. When you authenticate successfully, SSSD stores a hash of your credentials locally. If the domain controller is unreachable on your next login — network outage, laptop offline, VPN not connected — SSSD can verify your credentials against the local cache. You log in. You never knew the DC was down.</p>
<hr />
<h2 id="sssd-architecture">SSSD Architecture</h2>
<p>SSSD is a set of cooperating processes sharing a cache:</p>
<p><strong>Monitor</strong> — the parent process. Starts and restarts all other SSSD processes. If a responder or provider crashes, the monitor restarts it.</p>
<p><strong>Responders</strong> — answer queries from PAM and NSS. Each responder handles a specific interface:<br />
&#8211; <code class="" data-line="">sssd_nss</code> — answers <code class="" data-line="">getpwnam()</code>, <code class="" data-line="">getpwuid()</code>, <code class="" data-line="">getgrnam()</code>, <code class="" data-line="">initgroups()</code> calls<br />
&#8211; <code class="" data-line="">sssd_pam</code> — handles PAM authentication, account checks, and session management<br />
&#8211; <code class="" data-line="">sssd_autofs</code>, <code class="" data-line="">sssd_ssh</code>, <code class="" data-line="">sssd_sudo</code> — optional responders for specific services</p>
<p><strong>Providers</strong> — the backend processes that talk to the actual directory:<br />
&#8211; Each domain gets its own provider process (<code class="" data-line="">sssd_be[domain_name]</code>)<br />
&#8211; The provider connects to LDAP/Kerberos/AD, fetches data, and writes it to the shared cache<br />
&#8211; If the provider crashes or loses connectivity, responders fall back to serving from cache</p>
<p><strong>Cache</strong> — LDB files in <code class="" data-line="">/var/lib/sss/db/</code>. One database per configured domain, plus a cache for negative results (lookups that returned &#8220;not found&#8221;). The cache is an LDAP-like directory stored on disk — SSSD uses the same hierarchical structure for local storage as the remote directory uses.</p>
<pre><code class="" data-line=""># See the cache files
ls -la /var/lib/sss/db/
# cache_corp.com.ldb         ← user/group data for domain corp.com
# ccache_corp.com            ← Kerberos credential cache
# timestamps_corp.com.ldb   ← when entries were last refreshed
</code></pre>
<hr />
<h2 id="sssdconf-the-config-that-matters">sssd.conf: The Config That Matters</h2>
<p><code class="" data-line="">/etc/sssd/sssd.conf</code> has a <code class="" data-line="">[sssd]</code> section (global) and one <code class="" data-line="">[domain/name]</code> section per directory. The domain section is where almost all tuning happens.</p>
<pre><code class="" data-line="">[sssd]
services = nss, pam, sudo
domains = corp.com
config_file_version = 2

[domain/corp.com]
# What type of directory this is
id_provider = ad               # or: ldap, ipa, files
auth_provider = ad             # or: ldap, krb5, none
access_provider = ad           # controls who can log in

# The AD/LDAP server (can be a list for failover)
ad_domain = corp.com
ad_server = dc01.corp.com, dc02.corp.com

# Where to look for users and groups
ldap_search_base = dc=corp,dc=com

# Cache behavior
cache_credentials = true       # enable offline login
entry_cache_timeout = 5400     # how long before re-querying (seconds)
offline_credentials_expiration = 1  # days cached credentials stay valid offline

# What uid/gid range belongs to this domain (prevents UID conflicts)
ldap_id_mapping = true         # auto-map AD SIDs to UIDs (no uidNumber needed)
# OR for classical POSIX LDAP:
# ldap_id_mapping = false      # use uidNumber/gidNumber from directory

# Restrict logins to specific AD groups
# access_provider = simple
# simple_allow_groups = linux-admins, sre-team

# Home directory and shell defaults
override_homedir = /home/%u
default_shell = /bin/bash
fallback_homedir = /home/%u

# Enumerate all users (expensive on large dirs — disable unless needed)
enumerate = false
</code></pre>
<p>The two most commonly wrong settings:</p>
<p><strong><code class="" data-line="">ldap_search_base</code></strong> — if this doesn&#8217;t include the OU where your users live, SSSD won&#8217;t find them. On AD, the default searches the entire domain, which is usually correct. On OpenLDAP, you may need <code class="" data-line="">ou=people,dc=corp,dc=com</code>.</p>
<p><strong><code class="" data-line="">ldap_id_mapping</code></strong> — on AD, users typically don&#8217;t have <code class="" data-line="">uidNumber</code> attributes. Setting <code class="" data-line="">ldap_id_mapping = true</code> tells SSSD to derive a UID from the user&#8217;s SID algorithmically. This produces consistent UIDs across machines. Setting it to <code class="" data-line="">false</code> requires actual <code class="" data-line="">uidNumber</code> attributes in the directory.</p>
<hr />
<h2 id="credential-caching-and-offline-logins">Credential Caching and Offline Logins</h2>
<p>The cache is what separates SSSD from a simple proxy. When <code class="" data-line="">cache_credentials = true</code>:</p>
<ol>
<li>On successful authentication, SSSD stores a hash of the credential in the LDB cache</li>
<li>On the next authentication attempt, SSSD first tries the domain controller</li>
<li>If the DC is unreachable, SSSD falls back to the local credential hash</li>
<li>If the hash matches, login succeeds — even with no network</li>
</ol>
<p>The credential hash is not the cleartext password — it&#8217;s a salted hash stored in <code class="" data-line="">/var/lib/sss/db/cache_corp.com.ldb</code>. The security model is the same as <code class="" data-line="">/etc/shadow</code>: someone with root access to the machine can access the hashes.</p>
<p><code class="" data-line="">offline_credentials_expiration</code> controls how long cached credentials stay valid when the DC is unreachable. <code class="" data-line="">0</code> means forever (not recommended for high-security environments). <code class="" data-line="">1</code> means one day — after 24 hours offline, even cached credentials expire and the user must authenticate online.</p>
<hr />
<h2 id="the-debugging-toolkit">The Debugging Toolkit</h2>
<pre><code class="" data-line=""># 1. Is SSSD running?
systemctl status sssd
pgrep -a sssd    # shows all SSSD processes (monitor + responders + providers)

# 2. Domain connectivity status
sssctl domain-status corp.com
# Domain: corp.com
# Active servers:
#   LDAP: dc01.corp.com
#   KDC: dc01.corp.com
# Discovered servers:
#   LDAP: dc01.corp.com, dc02.corp.com

# 3. Can SSSD find a specific user?
sssctl user-checks vamshi
# user: vamshi
# user name: vamshi@corp.com
# POSIX attributes: UID=1001, GID=1001, ...
# Authentication: success (uses actual PAM auth stack)

# 4. What does NSS see?
getent passwd vamshi          # full passwd entry
id vamshi                     # uid, gid, groups

# 5. Flush stale cache entries
sss_cache -u vamshi           # invalidate one user
sss_cache -G engineers        # invalidate one group
sss_cache -E                  # invalidate everything (nuclear option)

# 6. Live logs
journalctl -u sssd -f         # tail all SSSD logs
# Then attempt login in another terminal — watch the auth flow in real time

# 7. Increase log verbosity temporarily
sssctl config-check            # validate sssd.conf syntax
# Edit sssd.conf: add debug_level = 6 under [domain/corp.com]
systemctl restart sssd
journalctl -u sssd -f          # now shows LDAP queries, cache hits/misses
</code></pre>
<p>The single most useful command is <code class="" data-line="">sssctl user-checks &lt;username&gt;</code>. It runs the full NSS + PAM auth stack internally and prints what SSSD would do on a real login — without creating a session or touching the running system.</p>
<hr />
<h2 id="breaking-sssd-and-what-each-failure-looks-like">Breaking SSSD (and What Each Failure Looks Like)</h2>
<p><strong>SSSD not running:</strong></p>
<pre><code class="" data-line="">ssh vamshi@server
# Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)
# getent passwd vamshi → (empty)
# Fix: systemctl start sssd
</code></pre>
<p><strong>Stale cache after AD password change:</strong></p>
<pre><code class="" data-line=""># User changed password in AD but SSSD still has old credential hash
ssh vamshi@server  # password accepted (wrong!) — cache hit with old hash
# Fix: sss_cache -u vamshi, then attempt login again
</code></pre>
<p><strong>Clock skew &gt; 5 minutes (breaks Kerberos):</strong></p>
<pre><code class="" data-line="">journalctl -u sssd | grep -i &quot;clock skew\|KDC\|kinit&quot;
# sssd_be[corp.com]: Kerberos authentication failed: Clock skew too great
# Fix: systemctl restart chronyd (or ntpd), verify time sync
</code></pre>
<p><strong><code class="" data-line="">ldap_search_base</code> wrong:</strong></p>
<pre><code class="" data-line="">getent passwd vamshi  # empty, but user exists in AD
sssctl user-checks vamshi  # &quot;User not found&quot;
# Check: ldap_search_base must include the OU containing users
# Test: ldapsearch -x -H ldap://dc -b &quot;ou=engineers,dc=corp,dc=com&quot; &quot;(uid=vamshi)&quot;
</code></pre>
<hr />
<h2 id="common-misconceptions"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Common Misconceptions</h2>
<p><strong>&#8220;Restarting SSSD logs everyone out.&#8221;</strong> Restarting SSSD doesn&#8217;t affect existing authenticated sessions. Active shell sessions, running processes — all unaffected. Only new authentication attempts are disrupted during the restart window, which takes a few seconds.</p>
<p><strong>&#8220;sss_cache -E fixes everything.&#8221;</strong> Flushing the entire cache forces SSSD to re-fetch all entries from the domain controller on the next lookup. On a system with many users or enumeration enabled, this can cause a brief spike in LDAP traffic and slow lookups. Use targeted flushes (<code class="" data-line="">-u username</code>, <code class="" data-line="">-G group</code>) when possible.</p>
<p><strong>&#8220;debug_level should always be high.&#8221;</strong> SSSD at <code class="" data-line="">debug_level = 9</code> logs every LDAP packet. On a production system with active logins, this generates gigabytes of logs quickly. Set it temporarily for debugging, then remove it and restart.</p>
<hr />
<h2 id="framework-alignment">Framework Alignment</h2>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Relevance</th>
</tr>
</thead>
<tbody>
<tr>
<td>CISSP Domain 5: Identity and Access Management</td>
<td>SSSD is the runtime implementation of enterprise identity integration on Linux — understanding its caching model, failover behavior, and credential storage is foundational to IAM operations</td>
</tr>
<tr>
<td>CISSP Domain 3: Security Architecture and Engineering</td>
<td>The credential cache design (<code class="" data-line="">/var/lib/sss/db/</code>) creates a local credential store with specific security properties — architects need to understand the offline login trade-off</td>
</tr>
<tr>
<td>CISSP Domain 7: Security Operations</td>
<td>SSSD is a critical security service — monitoring it, understanding its failure modes, and knowing how to recover it quickly are operational security skills</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li>SSSD is a three-tier system: responders (serve PAM/NSS), providers (talk to AD/LDAP), and a shared LDB cache — each tier is independently restartable</li>
<li>Credential caching enables offline logins — the security trade-off is a local hash store in <code class="" data-line="">/var/lib/sss/db/</code></li>
<li><code class="" data-line="">sssctl user-checks</code> is the first tool to reach for when a login fails — it simulates the full auth flow and shows exactly where it breaks</li>
<li><code class="" data-line="">ldap_id_mapping = true</code> is the right choice for AD environments without POSIX attributes; <code class="" data-line="">false</code> requires actual <code class="" data-line="">uidNumber</code>/<code class="" data-line="">gidNumber</code> in the directory</li>
<li>Clock skew over 5 minutes silently breaks Kerberos authentication — time sync is a hard dependency</li>
</ul>
<hr />
<h2 id="whats-next">What&#8217;s Next</h2>
<p>EP04 showed SSSD&#8217;s role as the caching and brokering layer. What it referenced repeatedly — &#8220;Kerberos ticket&#8221;, &#8220;KDC&#8221;, &#8220;GSSAPI&#8221; — is the authentication protocol that sits underneath AD-joined Linux logins. SSSD uses Kerberos to authenticate. LDAP carries the identity data. EP05 explains how Kerberos works.</p>
<p><em>Next: <a href="/how-kerberos-works-tickets-kdc/">How Kerberos Works: Tickets, KDC, and Why Enterprises Use It With LDAP</a></em></p>
<p>Get EP05 in your inbox when it publishes → <a href="https://linuxcent.com/subscribe">linuxcent.com/subscribe</a></p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fsssd-linux-authentication%2F&amp;linkname=SSSD%3A%20The%20Caching%20Daemon%20That%20Powers%20Every%20Enterprise%20Linux%20Login" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fsssd-linux-authentication%2F&amp;linkname=SSSD%3A%20The%20Caching%20Daemon%20That%20Powers%20Every%20Enterprise%20Linux%20Login" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fsssd-linux-authentication%2F&amp;linkname=SSSD%3A%20The%20Caching%20Daemon%20That%20Powers%20Every%20Enterprise%20Linux%20Login" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fsssd-linux-authentication%2F&amp;linkname=SSSD%3A%20The%20Caching%20Daemon%20That%20Powers%20Every%20Enterprise%20Linux%20Login" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fsssd-linux-authentication%2F&amp;linkname=SSSD%3A%20The%20Caching%20Daemon%20That%20Powers%20Every%20Enterprise%20Linux%20Login" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fsssd-linux-authentication%2F&amp;linkname=SSSD%3A%20The%20Caching%20Daemon%20That%20Powers%20Every%20Enterprise%20Linux%20Login" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fsssd-linux-authentication%2F&amp;linkname=SSSD%3A%20The%20Caching%20Daemon%20That%20Powers%20Every%20Enterprise%20Linux%20Login" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fsssd-linux-authentication%2F&#038;title=SSSD%3A%20The%20Caching%20Daemon%20That%20Powers%20Every%20Enterprise%20Linux%20Login" data-a2a-url="https://linuxcent.com/sssd-linux-authentication/" data-a2a-title="SSSD: The Caching Daemon That Powers Every Enterprise Linux Login"></a></p><p>The post <a href="https://linuxcent.com/sssd-linux-authentication/">SSSD: The Caching Daemon That Powers Every Enterprise Linux Login</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/sssd-linux-authentication/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1781</post-id>	</item>
		<item>
		<title>How LDAP Authentication Works on Linux: PAM, NSS, and the Login Stack</title>
		<link>https://linuxcent.com/ldap-authentication-linux-pam-nss/</link>
					<comments>https://linuxcent.com/ldap-authentication-linux-pam-nss/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Sun, 26 Apr 2026 19:46:19 +0000</pubDate>
				<category><![CDATA[Identity & Authentication]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux-security]]></category>
		<category><![CDATA[NSS]]></category>
		<category><![CDATA[PAM]]></category>
		<category><![CDATA[SSSD]]></category>
		<guid isPermaLink="false">https://linuxcent.com/ldap-authentication-linux-pam-nss/</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 8</span> <span class="rt-label rt-postfix">minutes</span></span>How LDAP authentication works on Linux: trace an SSH login through PAM, nsswitch.conf, and SSSD to understand exactly what happens before the shell opens.</p>
<p>The post <a href="https://linuxcent.com/ldap-authentication-linux-pam-nss/">How LDAP Authentication Works on Linux: PAM, NSS, and the Login Stack</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 8</span> <span class="rt-label rt-postfix">minutes</span></span><style>
pre{position:relative;background:#1e1e1e;color:#d4d4d4;
    padding:16px 16px 16px 20px;border-radius:6px;overflow-x:auto;
    font-family:'JetBrains Mono','Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
    font-size:.88em;line-height:1.6;border-left:4px solid #555}
code{background:#f4f4f4;padding:2px 5px;border-radius:3px;font-size:.9em}
pre code{background:transparent;padding:0;color:inherit}
pre[data-lang="bash"],pre[data-lang="sh"],
pre[data-lang="shell"],pre[data-lang="zsh"]{border-left-color:#4ec9b0}
pre[data-lang="yaml"],pre[data-lang="json"],
pre[data-lang="toml"],pre[data-lang="xml"]{border-left-color:#569cd6}
pre[data-lang="python"],pre[data-lang="go"],pre[data-lang="rust"],
pre[data-lang="java"],pre[data-lang="c"],pre[data-lang="cpp"]{border-left-color:#c586c0}
pre[data-lang="text"],pre[data-lang="output"],
pre[data-lang="console"]{border-left-color:#888}
.lc-copy-btn{position:absolute;top:8px;right:8px;background:#2d2d2d;color:#ccc;
    border:1px solid #444;border-radius:4px;padding:3px 9px;font-size:.75em;
    font-family:system-ui,sans-serif;cursor:pointer;opacity:0;
    transition:opacity .15s,background .15s;line-height:1.6}
pre:hover .lc-copy-btn{opacity:1}
.lc-copy-btn:hover{background:#3a3a3a;color:#fff}
.lc-copy-btn.copied{color:#4ec9b0;border-color:#4ec9b0}
.lc-lang-badge{position:absolute;top:8px;left:20px;font-family:system-ui,sans-serif;
    font-size:.7em;color:#666;text-transform:uppercase;letter-spacing:.04em;
    line-height:1;pointer-events:none;opacity:0;transition:opacity .15s}
pre:hover .lc-lang-badge{opacity:1}
table{border-collapse:collapse;width:100%;margin:16px 0}
th,td{border:1px solid #ddd;padding:10px 14px;text-align:left}
th{background:#f0f0f0;font-weight:600}
tr:nth-child(even){background:#fafafa}
</style>
<p><script>
(function(){
  if(window.__lcCodeEnhanced)return;
  window.__lcCodeEnhanced=true;
  function enhance(){
    document.querySelectorAll('pre').forEach(function(pre){
      var code=pre.querySelector('code');
      var lang='';
      if(code){var m=(code.className||'').match(/language-(\S+)/);if(m)lang=m[1].toLowerCase();}
      if(lang)pre.setAttribute('data-lang',lang);
      if(lang){var badge=document.createElement('span');badge.className='lc-lang-badge';badge.textContent=lang;pre.insertBefore(badge,pre.firstChild);}
      var btn=document.createElement('button');
      btn.className='lc-copy-btn';btn.textContent='Copy';btn.setAttribute('aria-label','Copy code to clipboard');
      pre.appendChild(btn);
      btn.addEventListener('click',function(){
        var text=code?code.innerText:pre.innerText;
        if(navigator.clipboard&&window.isSecureContext){
          navigator.clipboard.writeText(text).then(function(){ok(btn);}).catch(function(){fb(text,btn);});
        }else{fb(text,btn);}
      });
    });
  }
  function ok(btn){btn.textContent='Copied!';btn.classList.add('copied');setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied');},2000);}
  function fb(text,btn){
    try{var ta=document.createElement('textarea');ta.value=text;ta.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);ok(btn);}
    catch(e){btn.textContent='✗ Failed';setTimeout(function(){btn.textContent='Copy';},2000);}
  }
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',enhance);}else{enhance();}
})();
</script></p>
<p><em>The Identity Stack, Episode 3</em><br />
<a href="/what-is-ldap/">EP01: What Is LDAP</a> → <a href="/ldap-internals-directory-structure/">EP02: LDAP Internals</a> → <strong>EP03</strong> → <a href="/sssd-linux-authentication/">EP04: SSSD</a> → &#8230;</p>
<hr />
<h2 id="tldr">TL;DR</h2>
<ul>
<li>LDAP is a directory protocol — it stores identity information and can verify a password via Bind, but authentication on Linux runs through PAM, not directly through LDAP</li>
<li>NSS (<code class="" data-line="">/etc/nsswitch.conf</code>) answers &#8220;who is this user?&#8221; — it resolves UIDs, group memberships, and home directories by querying LDAP (or the local files, or SSSD)</li>
<li>PAM (<code class="" data-line="">/etc/pam.d/</code>) answers &#8220;are they allowed in?&#8221; — it enforces authentication, account validity, session setup, and password policy</li>
<li><code class="" data-line="">pam_ldap</code> (the old way) opened a direct LDAP connection on every login — fragile, no caching, broken when the LDAP server was unreachable</li>
<li><code class="" data-line="">pam_sss</code> (the modern way) delegates to SSSD, which caches credentials and handles failover — SSSD is the layer between Linux and the directory</li>
<li>Tracing a single SSH login: <code class="" data-line="">sshd</code> → PAM → <code class="" data-line="">pam_sss</code> → SSSD → LDAP Bind + Search → session created</li>
</ul>
<hr />
<h2 id="the-big-picture-one-ssh-login-four-layers">The Big Picture: One SSH Login, Four Layers</h2>
<pre><code class="" data-line="">You type: ssh vamshi@server.corp.com

  sshd
    │
    ▼
  PAM  (/etc/pam.d/sshd)          ← &quot;Is this user allowed in?&quot;
    │
    ├── pam_sss    (auth)          ← sends credentials to SSSD
    ├── pam_sss    (account)       ← checks account not expired/locked
    ├── pam_sss    (session)       ← logs the session open/close
    └── pam_mkhomedir (session)    ← creates /home/vamshi if it doesn&#039;t exist
    │
    ▼
  SSSD  (/etc/sssd/sssd.conf)     ← &quot;Let me check the directory&quot;
    │
    ├── NSS responder              ← answers getent, id, getpwnam
    └── LDAP/Kerberos provider     ← talks to the actual directory
    │
    ▼
  LDAP Server (AD / OpenLDAP)
    │
    ├── Bind: uid=vamshi + password (or Kerberos ticket)
    └── Search: posixAccount attrs for uid=vamshi
    │
    ▼
  Linux session created
  UID=1001, GID=1001, HOME=/home/vamshi, SHELL=/bin/bash
</code></pre>
<p>EP02 showed what the directory contains and what travels on the wire. What it left open is how Linux uses that to grant a login — and why LDAP is not, by itself, an authentication protocol.</p>
<hr />
<h2 id="why-ldap-is-not-an-authentication-protocol">Why LDAP Is Not an Authentication Protocol</h2>
<p>This is the confusion that trips people most. LDAP can verify a password — the Bind operation does exactly that. But authentication on Linux means something broader: checking credentials, checking account validity, enforcing password policy, setting up a session, creating a home directory. LDAP handles one piece of that. PAM handles the rest.</p>
<p>More precisely: LDAP doesn&#8217;t know what a Linux session is. It doesn&#8217;t know about <code class="" data-line="">/etc/pam.d/</code>. It doesn&#8217;t enforce login hours, account expiry, or concurrent session limits. It returns directory entries and verifies binds. The intelligence about what to do with those results lives in the Linux authentication stack.</p>
<p>When you run <code class="" data-line="">ssh vamshi@server</code>, the OS doesn&#8217;t open an LDAP connection and ask &#8220;can this user log in?&#8221; It calls PAM. PAM consults its configuration, and PAM decides whether to call LDAP (directly or via SSSD), whether to check the shadow file, whether to enforce MFA. LDAP is one possible backend. It&#8217;s not the gatekeeper.</p>
<hr />
<h2 id="nss-the-traffic-controller">NSS: The Traffic Controller</h2>
<p>Before PAM runs, Linux needs to know if the user exists at all. That&#8217;s NSS&#8217;s job.</p>
<p><code class="" data-line="">/etc/nsswitch.conf</code> is a routing table for name resolution. It tells the OS where to look when something asks &#8220;who is UID 1001?&#8221; or &#8220;what groups is vamshi in?&#8221;:</p>
<pre><code class="" data-line=""># /etc/nsswitch.conf

passwd:     files sss        ← user lookups: check /etc/passwd first, then SSSD
group:      files sss        ← group lookups: check /etc/group first, then SSSD
shadow:     files sss        ← shadow password lookups
hosts:      files dns        ← hostname lookups (not identity-related)
netgroup:   sss              ← NIS netgroups from SSSD only
automount:  sss              ← autofs maps from SSSD
</code></pre>
<p>Every call to <code class="" data-line="">getpwnam()</code>, <code class="" data-line="">getpwuid()</code>, <code class="" data-line="">getgrnam()</code>, <code class="" data-line="">getgrgid()</code> in any process — including <code class="" data-line="">sshd</code> — goes through NSS. The entries in nsswitch.conf control which backends are tried in order.</p>
<p>With <code class="" data-line="">passwd: files sss</code>, a lookup for user <code class="" data-line="">vamshi</code>:<br />
1. Checks <code class="" data-line="">/etc/passwd</code> — not found (vamshi is a domain user, not in local files)<br />
2. Queries SSSD — SSSD checks its cache, or queries LDAP, and returns the <code class="" data-line="">posixAccount</code> attributes</p>
<p>Without the <code class="" data-line="">sss</code> entry in <code class="" data-line="">passwd:</code>, domain users don&#8217;t exist on the system — <code class="" data-line="">getent passwd vamshi</code> returns nothing, <code class="" data-line="">id vamshi</code> fails, SSH login never gets to PAM&#8217;s authentication step.</p>
<pre><code class="" data-line=""># Verify NSS is routing to SSSD correctly
getent passwd vamshi
# vamshi:*:1001:1001:Vamshi K:/home/vamshi:/bin/bash

# If this returns nothing, NSS isn&#039;t reaching SSSD
# Check: systemctl status sssd &amp;&amp; grep passwd /etc/nsswitch.conf

# See what groups the user is in (NSS group lookup)
id vamshi
# uid=1001(vamshi) gid=1001(engineers) groups=1001(engineers),1002(ops)
</code></pre>
<hr />
<h2 id="pam-the-real-gatekeeper">PAM: The Real Gatekeeper</h2>
<p>PAM (Pluggable Authentication Modules) is the framework that lets Linux swap authentication backends without recompiling anything. Every service that needs to authenticate users — <code class="" data-line="">sshd</code>, <code class="" data-line="">sudo</code>, <code class="" data-line="">login</code>, <code class="" data-line="">su</code>, <code class="" data-line="">gdm</code> — has a PAM configuration file in <code class="" data-line="">/etc/pam.d/</code>.</p>
<p>Each PAM config defines four stacks:</p>
<pre><code class="" data-line="">auth        ← verify credentials (password, key, MFA)
account     ← check if the account is valid (not expired, not locked, login hours)
password    ← password change policy
session     ← set up/tear down the session (home dir, limits, logging)
</code></pre>
<p>A typical <code class="" data-line="">/etc/pam.d/sshd</code> on a system joined to AD via SSSD:</p>
<pre><code class="" data-line=""># /etc/pam.d/sshd

# auth stack — verify the user&#039;s credentials
auth    required      pam_sepermit.so
auth    substack      password-auth   ← usually includes pam_sss.so

# account stack — check account validity
account required      pam_nologin.so
account include       password-auth

# password stack — handle password changes
password include      password-auth

# session stack — set up the session
session required      pam_selinux.so close
session required      pam_loginuid.so
session optional      pam_keyinit.so force revoke
session include       password-auth
session optional      pam_motd.so
session optional      pam_mkhomedir.so skel=/etc/skel/ umask=0077
session required      pam_selinux.so open
</code></pre>
<p>The <code class="" data-line="">include</code> and <code class="" data-line="">substack</code> directives pull in shared stacks from other files (like <code class="" data-line="">/etc/pam.d/password-auth</code>). On a system with SSSD, <code class="" data-line="">password-auth</code> contains:</p>
<pre><code class="" data-line="">auth    required      pam_env.so
auth    sufficient    pam_sss.so      ← try SSSD first
auth    required      pam_deny.so     ← if pam_sss fails, deny

account required      pam_unix.so
account sufficient    pam_localuser.so
account sufficient    pam_sss.so      ← SSSD account check
account required      pam_permit.so

session optional      pam_sss.so      ← SSSD session tracking
</code></pre>
<p>The <code class="" data-line="">sufficient</code> flag means: if this module succeeds, stop checking this stack and consider it passed. <code class="" data-line="">required</code> means: this must pass (but continue checking other modules and report failure at the end). <code class="" data-line="">requisite</code> means: if this fails, stop immediately.</p>
<hr />
<h2 id="pam-control-flags-at-a-glance">PAM Control Flags at a Glance</h2>
<pre><code class="" data-line="">required   — must succeed; failure reported after remaining modules run
requisite  — must succeed; failure reported immediately, stack stops
sufficient — if success, stop stack (ignore remaining); failure continues
optional   — result ignored unless it&#039;s the only module in the stack
</code></pre>
<p>This matters for debugging. If <code class="" data-line="">pam_sss.so</code> is <code class="" data-line="">sufficient</code> and SSSD is down, PAM falls through to <code class="" data-line="">pam_deny.so</code> — login denied. If it were <code class="" data-line="">optional</code>, the login would proceed to the next module. The control flag is the policy decision.</p>
<hr />
<h2 id="the-old-way-pam_ldap">The Old Way: pam_ldap</h2>
<p>Before SSSD, Linux systems used <code class="" data-line="">pam_ldap</code> and <code class="" data-line="">nss_ldap</code> directly:</p>
<pre><code class="" data-line=""># Old /etc/pam.d/common-auth (Ubuntu pre-SSSD era)
auth    sufficient    pam_ldap.so    ← direct LDAP connection per login
auth    required      pam_unix.so nullok_secure

# Old /etc/nsswitch.conf
passwd: files ldap    ← nss_ldap for user lookups
group:  files ldap
</code></pre>
<p><code class="" data-line="">pam_ldap</code> opened a fresh LDAP connection on every login attempt. No caching. If the LDAP server was unreachable for 3 seconds, the login hung for 3 seconds — sometimes much longer. If the LDAP server was down, all domain logins failed immediately. Previously logged-in users with active sessions were fine; new logins simply didn&#8217;t work.</p>
<p><code class="" data-line="">nss_ldap</code> had the same problem for NSS lookups: every <code class="" data-line="">getpwnam()</code> call hit the LDAP server directly. On a busy system with many processes doing user lookups, this meant hundreds of LDAP queries per second, no connection reuse, and no way to survive a brief network blip.</p>
<p>The problems were structural:<br />
&#8211; No credential caching — offline logins impossible<br />
&#8211; No connection pooling — LDAP server saw one connection per login attempt<br />
&#8211; No failover logic — one LDAP server down meant all logins down<br />
&#8211; Slow timeouts that blocked login sessions</p>
<p>SSSD was built to fix all of this.</p>
<hr />
<h2 id="the-modern-way-pam_sss-sssd">The Modern Way: pam_sss + SSSD</h2>
<p><code class="" data-line="">pam_sss</code> doesn&#8217;t talk to LDAP directly. It&#8217;s a thin client that passes authentication requests to SSSD over a Unix domain socket. SSSD manages the LDAP connection, the credential cache, and the failover logic.</p>
<pre><code class="" data-line="">sshd  →  PAM (pam_sss)  →  SSSD (Unix socket)  →  LDAP server
                                   │
                                   └── credential cache
                                       (survives brief LDAP outages)
</code></pre>
<p>When <code class="" data-line="">pam_sss</code> sends a credential to SSSD:<br />
1. SSSD checks its in-memory cache — if the credential hash matches a recent successful auth, it can satisfy the request without hitting LDAP<br />
2. If not cached (or cache expired), SSSD sends a Bind to the LDAP server<br />
3. On success, SSSD caches the result and returns success to <code class="" data-line="">pam_sss</code><br />
4. <code class="" data-line="">pam_sss</code> returns PAM_SUCCESS, and the auth stack continues</p>
<p>The credential cache is what enables offline logins. If the LDAP server is unreachable and a user has authenticated successfully within the cache TTL (default: 1 day for credentials, configurable via <code class="" data-line="">cache_credentials = True</code> in sssd.conf), SSSD satisfies the auth from cache and the login succeeds. The user never knows the LDAP server was down.</p>
<hr />
<h2 id="tracing-a-full-ssh-login">Tracing a Full SSH Login</h2>
<p>Here&#8217;s every step of an SSH login for a domain user, in order:</p>
<pre><code class="" data-line="">1.  sshd accepts the TCP connection
2.  sshd calls PAM: pam_start(&quot;sshd&quot;, &quot;vamshi&quot;, ...)

3.  PAM auth stack runs pam_sss:
      pam_sss sends credentials to SSSD via /var/lib/sss/pipes/pam

4.  SSSD auth provider:
      a. Check credential cache — miss (first login)
      b. Resolve user: NSS lookup for uid=vamshi
         → SSSD LDAP provider searches dc=corp,dc=com for (uid=vamshi)
         → Returns: uidNumber=1001, gidNumber=1001, homeDirectory=/home/vamshi
      c. Authenticate: LDAP Simple Bind as uid=vamshi,ou=engineers,dc=corp,dc=com
         → Server returns: success
      d. Cache the credential hash + POSIX attrs

5.  SSSD returns PAM_SUCCESS to pam_sss

6.  PAM account stack runs pam_sss:
      SSSD checks: account not expired, not locked, login permitted
      → PAM_ACCT_MGMT success

7.  PAM session stack:
      pam_loginuid sets /proc/self/loginuid = 1001
      pam_mkhomedir creates /home/vamshi if missing
      pam_sss opens session (records in SSSD session tracking)

8.  sshd creates the shell, sets environment:
      USER=vamshi, HOME=/home/vamshi, SHELL=/bin/bash, LOGNAME=vamshi

9.  Shell prompt appears
</code></pre>
<p>Steps 4b and 4c are the only two LDAP operations in the entire login flow: one Search to resolve the user&#8217;s attributes, one Bind to verify the password. Everything else is PAM and SSSD.</p>
<hr />
<h2 id="debugging-the-stack">Debugging the Stack</h2>
<p>When a login fails, the failure could be in any layer. Work top-down:</p>
<pre><code class="" data-line=""># 1. Does NSS resolve the user at all?
getent passwd vamshi
# If empty: NSS isn&#039;t reaching SSSD, or SSSD isn&#039;t finding the user in LDAP

# 2. Is SSSD running and healthy?
systemctl status sssd
sssctl domain-status corp.com      # shows SSSD&#039;s view of domain connectivity

# 3. What does SSSD think about the user?
sssctl user-checks vamshi          # runs auth + account checks internally
id vamshi                          # forces NSS resolution and shows group memberships

# 4. What does SSSD&#039;s log say?
journalctl -u sssd -f              # tail SSSD logs live, then attempt login

# 5. Can you reach the LDAP server at all?
ldapsearch -x -H ldap://dc.corp.com \
  -D &quot;cn=svc-ldap,ou=services,dc=corp,dc=com&quot; \
  -w &quot;password&quot; \
  -b &quot;dc=corp,dc=com&quot; \
  &quot;(uid=vamshi)&quot; dn

# 6. Force a cache flush if entries are stale
sss_cache -u vamshi                # invalidate this user&#039;s cache entry
sss_cache -G engineers             # invalidate a group
</code></pre>
<p>The <code class="" data-line="">sssctl user-checks</code> command is the single most useful diagnostic — it simulates the full PAM auth + account check flow without actually creating a session, and prints exactly what SSSD would do on a real login attempt.</p>
<hr />
<h2 id="common-misconceptions"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Common Misconceptions</h2>
<p><strong>&#8220;If ldapsearch works, SSH login should work.&#8221;</strong> Not necessarily. <code class="" data-line="">ldapsearch</code> tests the LDAP layer. An SSH login requires NSS to resolve the user, PAM to authenticate, SSSD to be running and configured correctly, and <code class="" data-line="">pam_mkhomedir</code> to create the home directory if it&#8217;s the first login. Any of these can fail independently.</p>
<p><strong>&#8220;pam_ldap and pam_sss do the same thing.&#8221;</strong> They have the same job (authenticate via LDAP) but completely different architectures. <code class="" data-line="">pam_ldap</code> is a direct-connect, no-cache module. <code class="" data-line="">pam_sss</code> is a client of SSSD, which provides caching, connection pooling, failover, and offline support. On any modern system, you want <code class="" data-line="">pam_sss</code>.</p>
<p><strong>&#8220;nsswitch.conf order doesn&#8217;t matter much.&#8221;</strong> It matters exactly as much as the order suggests. <code class="" data-line="">passwd: files sss</code> means local <code class="" data-line="">/etc/passwd</code> is always checked first — if a domain username collides with a local user, the local account wins. This is the intended behavior (local accounts should always be reachable), but it means you&#8217;ll never override a local account with a directory entry.</p>
<p><strong>&#8220;SSSD cache = security risk.&#8221;</strong> The cache stores a credential hash, not the cleartext password. An attacker with access to the SSSD cache database (<code class="" data-line="">/var/lib/sss/db/</code>) would see hashed credentials — the same situation as <code class="" data-line="">/etc/shadow</code>. The real concern is whether offline authentication is appropriate for your security posture; it can be disabled with <code class="" data-line="">offline_credentials_expiration = 0</code>.</p>
<hr />
<h2 id="framework-alignment">Framework Alignment</h2>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Relevance</th>
</tr>
</thead>
<tbody>
<tr>
<td>CISSP Domain 5: Identity and Access Management</td>
<td>PAM is the enforcement layer for authentication policy on Linux — understanding its stack is foundational to any Linux IAM deployment</td>
</tr>
<tr>
<td>CISSP Domain 3: Security Architecture and Engineering</td>
<td>The separation between NSS (resolution) and PAM (authentication) is an architectural boundary — misunderstanding it leads to misconfigured systems where account checks are bypassed</td>
</tr>
<tr>
<td>CISSP Domain 4: Communications and Network Security</td>
<td>pam_ldap vs pam_sss affects whether credentials travel over a direct LDAP connection (one socket per login, no TLS guarantee) or through SSSD&#8217;s managed, pooled connection</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li>LDAP alone is not an authentication protocol for Linux — authentication flows through PAM, and LDAP is one of PAM&#8217;s possible backends</li>
<li>NSS (<code class="" data-line="">/etc/nsswitch.conf</code>) resolves user identity (who is UID 1001?); PAM enforces it (are they allowed in?)</li>
<li><code class="" data-line="">pam_ldap</code> talks to LDAP directly — no cache, no failover, login blocked when LDAP is unreachable</li>
<li><code class="" data-line="">pam_sss</code> delegates to SSSD — credential caching, connection pooling, offline login, and failover are all built in</li>
<li>A full SSH login touches LDAP exactly twice: one Search for POSIX attributes, one Bind to verify the password</li>
<li>When login fails, debug top-down: NSS resolution → SSSD status → LDAP reachability → PAM config</li>
</ul>
<hr />
<h2 id="whats-next">What&#8217;s Next</h2>
<p>EP03 showed how authentication reaches LDAP — through PAM, through SSSD, through a Bind. What it assumed is that SSSD is healthy and the LDAP server is reachable. The moment either goes wrong, the behavior depends entirely on how SSSD is configured — its cache TTLs, its failover order, its offline credential policy.</p>
<p>EP04 goes inside SSSD: the architecture, the sssd.conf knobs that matter, how to read the logs, and how to break it intentionally and fix it.</p>
<p><em>Next: <a href="/sssd-linux-authentication/">SSSD: The Caching Daemon That Powers Every Enterprise Linux Login</a></em></p>
<p>Get EP04 in your inbox when it publishes → <a href="https://linuxcent.com/subscribe">linuxcent.com/subscribe</a></p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-authentication-linux-pam-nss%2F&amp;linkname=How%20LDAP%20Authentication%20Works%20on%20Linux%3A%20PAM%2C%20NSS%2C%20and%20the%20Login%20Stack" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-authentication-linux-pam-nss%2F&amp;linkname=How%20LDAP%20Authentication%20Works%20on%20Linux%3A%20PAM%2C%20NSS%2C%20and%20the%20Login%20Stack" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-authentication-linux-pam-nss%2F&amp;linkname=How%20LDAP%20Authentication%20Works%20on%20Linux%3A%20PAM%2C%20NSS%2C%20and%20the%20Login%20Stack" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-authentication-linux-pam-nss%2F&amp;linkname=How%20LDAP%20Authentication%20Works%20on%20Linux%3A%20PAM%2C%20NSS%2C%20and%20the%20Login%20Stack" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-authentication-linux-pam-nss%2F&amp;linkname=How%20LDAP%20Authentication%20Works%20on%20Linux%3A%20PAM%2C%20NSS%2C%20and%20the%20Login%20Stack" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-authentication-linux-pam-nss%2F&amp;linkname=How%20LDAP%20Authentication%20Works%20on%20Linux%3A%20PAM%2C%20NSS%2C%20and%20the%20Login%20Stack" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-authentication-linux-pam-nss%2F&amp;linkname=How%20LDAP%20Authentication%20Works%20on%20Linux%3A%20PAM%2C%20NSS%2C%20and%20the%20Login%20Stack" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fldap-authentication-linux-pam-nss%2F&#038;title=How%20LDAP%20Authentication%20Works%20on%20Linux%3A%20PAM%2C%20NSS%2C%20and%20the%20Login%20Stack" data-a2a-url="https://linuxcent.com/ldap-authentication-linux-pam-nss/" data-a2a-title="How LDAP Authentication Works on Linux: PAM, NSS, and the Login Stack"></a></p><p>The post <a href="https://linuxcent.com/ldap-authentication-linux-pam-nss/">How LDAP Authentication Works on Linux: PAM, NSS, and the Login Stack</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/ldap-authentication-linux-pam-nss/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1777</post-id>	</item>
		<item>
		<title>LDAP Internals: The Directory Tree, Schema, and What Travels on the Wire</title>
		<link>https://linuxcent.com/ldap-internals-directory-structure/</link>
					<comments>https://linuxcent.com/ldap-internals-directory-structure/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Fri, 24 Apr 2026 19:41:04 +0000</pubDate>
				<category><![CDATA[Identity & Authentication]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Directory Services]]></category>
		<category><![CDATA[Identity Management]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[LDAP Schema]]></category>
		<category><![CDATA[ldapsearch]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://linuxcent.com/ldap-internals-directory-structure/</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 12</span> <span class="rt-label rt-postfix">minutes</span></span>Understand LDAP internals: the DIT hierarchy, DN syntax, object classes, schema, and the BER-encoded bytes that travel from directory server to authentication daemon.</p>
<p>The post <a href="https://linuxcent.com/ldap-internals-directory-structure/">LDAP Internals: The Directory Tree, Schema, and What Travels on the Wire</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 12</span> <span class="rt-label rt-postfix">minutes</span></span><style>
pre{position:relative;background:#1e1e1e;color:#d4d4d4;
    padding:16px 16px 16px 20px;border-radius:6px;overflow-x:auto;
    font-family:'JetBrains Mono','Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
    font-size:.88em;line-height:1.6;border-left:4px solid #555}
code{background:#f4f4f4;padding:2px 5px;border-radius:3px;font-size:.9em}
pre code{background:transparent;padding:0;color:inherit}
pre[data-lang="bash"],pre[data-lang="sh"],
pre[data-lang="shell"],pre[data-lang="zsh"]{border-left-color:#4ec9b0}
pre[data-lang="yaml"],pre[data-lang="json"],
pre[data-lang="toml"],pre[data-lang="xml"]{border-left-color:#569cd6}
pre[data-lang="python"],pre[data-lang="go"],pre[data-lang="rust"],
pre[data-lang="java"],pre[data-lang="c"],pre[data-lang="cpp"]{border-left-color:#c586c0}
pre[data-lang="text"],pre[data-lang="output"],
pre[data-lang="console"]{border-left-color:#888}
.lc-copy-btn{position:absolute;top:8px;right:8px;background:#2d2d2d;color:#ccc;
    border:1px solid #444;border-radius:4px;padding:3px 9px;font-size:.75em;
    font-family:system-ui,sans-serif;cursor:pointer;opacity:0;
    transition:opacity .15s,background .15s;line-height:1.6}
pre:hover .lc-copy-btn{opacity:1}
.lc-copy-btn:hover{background:#3a3a3a;color:#fff}
.lc-copy-btn.copied{color:#4ec9b0;border-color:#4ec9b0}
.lc-lang-badge{position:absolute;top:8px;left:20px;font-family:system-ui,sans-serif;
    font-size:.7em;color:#666;text-transform:uppercase;letter-spacing:.04em;
    line-height:1;pointer-events:none;opacity:0;transition:opacity .15s}
pre:hover .lc-lang-badge{opacity:1}
table{border-collapse:collapse;width:100%;margin:16px 0}
th,td{border:1px solid #ddd;padding:10px 14px;text-align:left}
th{background:#f0f0f0;font-weight:600}
tr:nth-child(even){background:#fafafa}
</style>
<p><script>
(function(){
  if(window.__lcCodeEnhanced)return;
  window.__lcCodeEnhanced=true;
  function enhance(){
    document.querySelectorAll('pre').forEach(function(pre){
      var code=pre.querySelector('code');
      var lang='';
      if(code){var m=(code.className||'').match(/language-(\S+)/);if(m)lang=m[1].toLowerCase();}
      if(lang)pre.setAttribute('data-lang',lang);
      if(lang){var badge=document.createElement('span');badge.className='lc-lang-badge';badge.textContent=lang;pre.insertBefore(badge,pre.firstChild);}
      var btn=document.createElement('button');
      btn.className='lc-copy-btn';btn.textContent='Copy';btn.setAttribute('aria-label','Copy code to clipboard');
      pre.appendChild(btn);
      btn.addEventListener('click',function(){
        var text=code?code.innerText:pre.innerText;
        if(navigator.clipboard&&window.isSecureContext){
          navigator.clipboard.writeText(text).then(function(){ok(btn);}).catch(function(){fb(text,btn);});
        }else{fb(text,btn);}
      });
    });
  }
  function ok(btn){btn.textContent='Copied!';btn.classList.add('copied');setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied');},2000);}
  function fb(text,btn){
    try{var ta=document.createElement('textarea');ta.value=text;ta.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);ok(btn);}
    catch(e){btn.textContent='✗ Failed';setTimeout(function(){btn.textContent='Copy';},2000);}
  }
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',enhance);}else{enhance();}
})();
</script></p>
<p><em>The Identity Stack, Episode 2</em><br />
<a href="/what-is-ldap/">EP01: What Is LDAP</a> → <strong>EP02</strong> → <a href="/ldap-authentication-linux-pam-nss/">EP03: LDAP Authentication on Linux</a> → &#8230;</p>
<hr />
<h2 id="tldr">TL;DR</h2>
<ul>
<li>The Directory Information Tree (DIT) is the hierarchical database LDAP stores — every entry lives at a unique path described by its Distinguished Name (DN)</li>
<li>Object classes define what attributes an entry is allowed or required to have — <code class="" data-line="">posixAccount</code> adds UID, GID, and home directory; <code class="" data-line="">inetOrgPerson</code> adds email and display name</li>
<li>Schema is the rulebook: which attribute types exist across the entire directory, what syntax each follows, and which object classes require or permit them</li>
<li>An LDAP Search sends four things: a base DN, a scope (base/one/sub), a filter like <code class="" data-line="">(uid=vamshi)</code>, and a list of attributes to return — the server traverses the tree and returns LDIF</li>
<li>Every LDAP message on the wire is BER-encoded (Basic Encoding Rules, a subset of ASN.1) — a compact binary format, not text</li>
<li><code class="" data-line="">ldapsearch</code> output is LDIF (LDAP Data Interchange Format) — the human-readable representation of what the BER payload carried</li>
</ul>
<hr />
<h2 id="the-big-picture-from-ldapsearch-to-directory-entry">The Big Picture: From ldapsearch to Directory Entry</h2>
<pre><code class="" data-line="">ldapsearch -x -H ldap://dc.corp.com -b &quot;dc=corp,dc=com&quot; &quot;(uid=vamshi)&quot; cn mail uidNumber
     │
     │  TCP port 389 (or 636 for LDAPS)
     │  BER-encoded SearchRequest
     ▼
┌─────────────────────────────────────────────────┐
│  LDAP Server (AD / OpenLDAP / 389-DS / FreeIPA)  │
│                                                   │
│  Directory Information Tree                       │
│                                                   │
│  dc=corp,dc=com                    ← search base  │
│    └── ou=engineers                ← scope: sub   │
│          ├── uid=alice                            │
│          └── uid=vamshi  ← filter match           │
│                cn: vamshi                         │
│                mail: vamshi@corp.com              │
│                uidNumber: 1001                    │
└─────────────────────────────────────────────────┘
     │
     │  BER-encoded SearchResultEntry
     ▼
# LDIF output on your terminal
dn: uid=vamshi,ou=engineers,dc=corp,dc=com
cn: vamshi
mail: vamshi@corp.com
uidNumber: 1001
</code></pre>
<p>LDAP internals are the mechanics between the command you type and the directory entry you get back. EP01 explained why LDAP was invented. This episode explains what it actually does when you run it.</p>
<hr />
<h2 id="the-directory-information-tree">The Directory Information Tree</h2>
<p>EP01 introduced the DIT as a concept inherited from X.500. Here&#8217;s what it actually looks like inside a directory.</p>
<p>Every LDAP directory has a root — the base DN — from which all entries descend. For a company called Corp with a domain <code class="" data-line="">corp.com</code>, the base is typically <code class="" data-line="">dc=corp,dc=com</code>. Below that, the tree branches into organizational units, and below those, individual entries for people, groups, services, and anything else the directory administrator decided to model.</p>
<pre><code class="" data-line="">dc=corp,dc=com                          ← domain root (base DN)
│
├── ou=people                           ← organizational unit: people
│     ├── uid=alice                     ← user entry
│     ├── uid=vamshi
│     └── uid=bob
│
├── ou=groups                           ← organizational unit: groups
│     ├── cn=engineers
│     └── cn=ops
│
├── ou=services                         ← organizational unit: service accounts
│     ├── cn=jenkins
│     └── cn=gitlab-runner
│
└── ou=hosts                            ← organizational unit: machines
      ├── cn=web01.corp.com
      └── cn=db01.corp.com
</code></pre>
<p>This hierarchy is not a file system and not a relational database. It is specifically optimized for reads — the query &#8220;give me everything about this user&#8221; is the operation the protocol is built around. Writes are infrequent. Reads are constant.</p>
<p>Every entry in the tree has exactly one parent. There are no cross-links between branches, no foreign keys. The tree is the structure. An entry&#8217;s position in the tree is what defines it.</p>
<hr />
<h2 id="distinguished-names-reading-the-path">Distinguished Names: Reading the Path</h2>
<p>The Distinguished Name (DN) is how you address any entry in the directory. It reads right-to-left, from the leaf to the root, with each component separated by a comma.</p>
<pre><code class="" data-line="">uid=vamshi,ou=engineers,dc=corp,dc=com

Reading right-to-left:
  dc=corp,dc=com       ← domain: corp.com
  ou=engineers         ← organizational unit: engineers
  uid=vamshi           ← this specific entry: user &quot;vamshi&quot;
</code></pre>
<p>Each component of a DN — <code class="" data-line="">uid=vamshi</code>, <code class="" data-line="">ou=engineers</code>, <code class="" data-line="">dc=corp</code> — is a Relative Distinguished Name (RDN). The RDN is the attribute-value pair that uniquely identifies the entry within its parent container. Two users in the same <code class="" data-line="">ou=engineers</code> cannot both have <code class="" data-line="">uid=vamshi</code> — that would create two entries with identical DNs, which the directory won&#8217;t allow.</p>
<p>Common RDN attribute types and what they mean:</p>
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Stands for</th>
<th>Typical use</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="" data-line="">dc</code></td>
<td>Domain Component</td>
<td>Domain name segments (<code class="" data-line="">dc=corp,dc=com</code> = corp.com)</td>
</tr>
<tr>
<td><code class="" data-line="">ou</code></td>
<td>Organizational Unit</td>
<td>Container for grouping entries</td>
</tr>
<tr>
<td><code class="" data-line="">cn</code></td>
<td>Common Name</td>
<td>Groups, service accounts, human-readable name</td>
</tr>
<tr>
<td><code class="" data-line="">uid</code></td>
<td>User ID</td>
<td>Linux username — the standard RDN for user entries</td>
</tr>
<tr>
<td><code class="" data-line="">o</code></td>
<td>Organization</td>
<td>Top-level org containers (less common in modern setups)</td>
</tr>
</tbody>
</table>
<p>When your Linux system calls <code class="" data-line="">getent passwd vamshi</code>, SSSD translates that into an LDAP Search for an entry where <code class="" data-line="">uid=vamshi</code> somewhere under the configured base DN. The full DN comes back with the result, but what your system cares about are the attributes inside it.</p>
<hr />
<h2 id="object-classes-and-schema">Object Classes and Schema</h2>
<p>Every entry in the directory has a <code class="" data-line="">objectClass</code> attribute — usually several values. Object classes define what attributes the entry is allowed or required to have.</p>
<pre><code class="" data-line=""># A typical user entry&#039;s object classes
dn: uid=vamshi,ou=engineers,dc=corp,dc=com
objectClass: top
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
</code></pre>
<p>Each object class contributes a set of attributes — some required (<code class="" data-line="">MUST</code>), some optional (<code class="" data-line="">MAY</code>):</p>
<pre><code class="" data-line="">objectClass: posixAccount
  MUST: cn, uid, uidNumber, gidNumber, homeDirectory
  MAY:  userPassword, loginShell, gecos, description

objectClass: inetOrgPerson
  MUST: sn (surname), cn
  MAY:  mail, telephoneNumber, displayName, jpegPhoto, ...

objectClass: shadowAccount
  MUST: uid
  MAY:  shadowLastChange, shadowMin, shadowMax, shadowWarning, ...
</code></pre>
<p>When Linux authenticates a user via LDAP, it needs the <code class="" data-line="">posixAccount</code> attributes: <code class="" data-line="">uidNumber</code> (the numeric UID), <code class="" data-line="">gidNumber</code>, <code class="" data-line="">homeDirectory</code>, and <code class="" data-line="">loginShell</code>. Without <code class="" data-line="">posixAccount</code>, the user entry exists in the directory but can&#8217;t be used for Linux logins — <code class="" data-line="">getent passwd</code> will return nothing.</p>
<p>Object classes are grouped into three kinds:</p>
<p>Groups in LDAP use their own object class:</p>
<pre><code class="" data-line="">objectClass: groupOfNames
  MUST: cn, member
  MAY:  description, owner, ...

# A group entry looks like this:
dn: cn=engineers,ou=groups,dc=corp,dc=com
objectClass: groupOfNames
cn: engineers
member: uid=vamshi,ou=engineers,dc=corp,dc=com
member: uid=alice,ou=engineers,dc=corp,dc=com
</code></pre>
<p><code class="" data-line="">groupOfNames</code> stores members as full DNs — which is why the SSSD group search filter is <code class="" data-line="">(member=uid=vamshi,ou=...)</code> rather than <code class="" data-line="">(member=vamshi)</code>. The directory stores the exact path to each member entry. <code class="" data-line="">posixGroup</code> is the alternative, which stores the <code class="" data-line="">memberUid</code> as a bare username string instead of a DN — Active Directory uses <code class="" data-line="">groupOfNames</code>; pure POSIX environments often use <code class="" data-line="">posixGroup</code>.</p>
<p>Object classes are grouped into three kinds:</p>
<p><strong>Structural</strong> — defines what the entry fundamentally is. Every entry must have exactly one structural class. <code class="" data-line="">posixAccount</code> is structural.</p>
<p><strong>Auxiliary</strong> — adds additional attributes to an existing entry. <code class="" data-line="">shadowAccount</code> and <code class="" data-line="">inetOrgPerson</code> can be auxiliary. You can stack multiple auxiliary classes on a single entry.</p>
<p><strong>Abstract</strong> — base classes that other classes inherit from. <code class="" data-line="">top</code> is the root abstract class that every entry implicitly has. You never add <code class="" data-line="">top</code> to an entry; it&#8217;s always there.</p>
<h3 id="schema-the-directorys-type-system">Schema: The Directory&#8217;s Type System</h3>
<p>Schema is the global rulebook for the entire directory. It defines:</p>
<ul>
<li><strong>Attribute type definitions</strong> — what each attribute is named, what syntax it uses (a string? an integer? a binary blob?), whether it&#8217;s case-sensitive, whether multiple values are allowed</li>
<li><strong>Object class definitions</strong> — which attributes each class requires or permits</li>
<li><strong>Matching rules</strong> — how equality comparisons work for each attribute type</li>
</ul>
<p>The schema is stored in the directory itself, under a special entry at <code class="" data-line="">cn=schema,cn=config</code> (OpenLDAP) or <code class="" data-line="">cn=Schema,cn=Configuration</code> (Active Directory). You can query it:</p>
<pre><code class="" data-line=""># View the schema for the posixAccount object class
ldapsearch -x -H ldap://your-dc \
  -b &quot;cn=schema,cn=config&quot; \
  &quot;(objectClass=olcObjectClasses)&quot; \
  olcObjectClasses | grep -A 10 &quot;posixAccount&quot;

# Output:
# olcObjectClasses: ( 1.3.6.1.1.1.2.0
#   NAME &#039;posixAccount&#039;
#   DESC &#039;Abstraction of an account with POSIX attributes&#039;
#   SUP top
#   AUXILIARY
#   MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory )
#   MAY ( userPassword $ loginShell $ gecos $ description ) )
</code></pre>
<p>That OID (<code class="" data-line="">1.3.6.1.1.1.2.0</code>) is the globally unique identifier for the <code class="" data-line="">posixAccount</code> object class. Every object class and attribute type in every LDAP directory on the planet has a unique OID assigned by an authority. This is how schema interoperability works across different directory implementations — OpenLDAP, Active Directory, and 389-DS can all understand each other&#8217;s <code class="" data-line="">posixAccount</code> entries because they share the same OID.</p>
<hr />
<h2 id="ldap-operations-what-actually-runs">LDAP Operations: What Actually Runs</h2>
<p>LDAP defines eight operations. Day-to-day authentication uses two: Bind and Search.</p>
<pre><code class="" data-line="">LDAP Operation Set
──────────────────
Bind        ← authenticate (prove identity)
Search      ← query the directory
Add         ← create a new entry
Modify      ← change attributes on an existing entry
Delete      ← remove an entry
ModifyDN    ← rename or move an entry
Compare     ← test if an attribute has a specific value
Abandon     ← cancel an outstanding operation
</code></pre>
<h3 id="bind-proving-who-you-are">Bind: Proving Who You Are</h3>
<p>Before any authenticated operation, the client sends a Bind request. There are two types:</p>
<p><strong>Simple Bind</strong> — the client sends its DN and password in the clear (or over TLS). This is what <code class="" data-line="">-x</code> in <code class="" data-line="">ldapsearch</code> means: simple authentication.</p>
<pre><code class="" data-line=""># Simple bind as a service account
ldapsearch -x \
  -D &quot;cn=svc-ldap-reader,ou=services,dc=corp,dc=com&quot; \
  -w &quot;service-account-password&quot; \
  -H ldap://dc.corp.com \
  -b &quot;dc=corp,dc=com&quot; \
  &quot;(uid=vamshi)&quot;
</code></pre>
<p><strong>SASL Bind</strong> — the client uses an authentication mechanism registered with SASL (Simple Authentication and Security Layer). Kerberos (via the GSSAPI mechanism) is the most common. EP05 covers Kerberos in detail.</p>
<pre><code class="" data-line=""># SASL bind using Kerberos (after kinit)
ldapsearch -Y GSSAPI \
  -H ldap://dc.corp.com \
  -b &quot;dc=corp,dc=com&quot; \
  &quot;(uid=vamshi)&quot;
</code></pre>
<p>An anonymous Bind (no DN, no password) is also valid for directories configured to allow anonymous reads. Many public LDAP directories (and some internal ones, misconfigured) allow this.</p>
<h3 id="search-the-core-operation">Search: The Core Operation</h3>
<p>A Search request has five required parameters:</p>
<pre><code class="" data-line="">baseObject   — where in the DIT to start (e.g., &quot;dc=corp,dc=com&quot;)
scope        — how deep to look
               base    = only the base entry itself
               one     = one level below base (immediate children)
               sub     = entire subtree below base (most common)
derefAliases — how to handle alias entries (usually derefAlways)
filter       — what to match (e.g., &quot;(uid=vamshi)&quot;)
attributes   — which attributes to return (empty = return all)
</code></pre>
<p>When SSSD authenticates a user login, it runs exactly two Search operations:</p>
<pre><code class="" data-line="">Search 1 — find the user&#039;s entry
  base:       dc=corp,dc=com
  scope:      sub
  filter:     (uid=vamshi)
  attributes: dn, uid, uidNumber, gidNumber, homeDirectory, loginShell

Search 2 — find the user&#039;s group memberships
  base:       dc=corp,dc=com
  scope:      sub
  filter:     (member=uid=vamshi,ou=engineers,dc=corp,dc=com)
  attributes: dn, cn, gidNumber
</code></pre>
<p>The first search locates the user entry and retrieves the POSIX attributes. The second finds all group entries that contain the user&#8217;s DN as a member. These two queries are the complete basis for a Linux login over LDAP.</p>
<h3 id="search-filters">Search Filters</h3>
<p>LDAP filters follow a prefix (Polish notation) syntax. Every filter is wrapped in parentheses:</p>
<pre><code class="" data-line=""># Simple equality
(uid=vamshi)

# Presence — entry has this attribute at all
(mail=*)

# Substring match
(cn=vam*)

# Comparison
(uidNumber&gt;=1000)

# Logical AND — both conditions must match
(&amp;(objectClass=posixAccount)(uid=vamshi))

# Logical OR — either condition matches
(|(uid=vamshi)(mail=vamshi@corp.com))

# Logical NOT
(!(uid=guest))

# Combined — posixAccount entries with UID &gt;= 1000 and no disabled flag
(&amp;(objectClass=posixAccount)(uidNumber&gt;=1000)(!(pwdAccountLockedTime=*)))
</code></pre>
<p>The <code class="" data-line="">&amp;</code> and <code class="" data-line="">|</code> operators take any number of operands. Filter syntax looks strange the first time but is unambiguous and compact — which matters when you&#8217;re encoding it into BER for the wire.</p>
<hr />
<h2 id="what-actually-travels-on-the-wire">What Actually Travels on the Wire</h2>
<p>Every LDAP message is encoded in BER (Basic Encoding Rules), a binary subset of ASN.1. LDAP is not a text protocol.</p>
<p>When you run <code class="" data-line="">ldapsearch</code>, the tool constructs a BER-encoded <code class="" data-line="">SearchRequest</code> message and sends it over TCP. The server responds with one or more <code class="" data-line="">SearchResultEntry</code> messages (one per matching entry), followed by a <code class="" data-line="">SearchResultDone</code>. All of these are BER.</p>
<p>BER uses a type-length-value (TLV) encoding:</p>
<pre><code class="" data-line="">Tag byte(s)    — what type of data this is
Length byte(s) — how many bytes of data follow
Value byte(s)  — the actual data
</code></pre>
<p>A minimal LDAP SearchRequest for <code class="" data-line="">ldapsearch -x -b &quot;dc=corp,dc=com&quot; &quot;(uid=vamshi)&quot; uid</code> looks like this on the wire:</p>
<pre><code class="" data-line="">30 45          ← SEQUENCE (LDAPMessage)
  02 01 01     ← INTEGER 1 (messageID = 1)
  63 40        ← [APPLICATION 3] SearchRequest
    04 11       ← OCTET STRING: baseObject
      64 63 3d  ← &quot;dc=corp,dc=com&quot; (20 bytes)
      63 6f 72
      70 2c 64
      63 3d 63
      6f 6d
    0a 01 02   ← ENUMERATED: scope = wholeSubtree (2)
    0a 01 03   ← ENUMERATED: derefAliases = derefAlways (3)
    02 01 00   ← INTEGER: sizeLimit = 0 (unlimited)
    02 01 00   ← INTEGER: timeLimit = 0 (unlimited)
    01 01 00   ← BOOLEAN: typesOnly = false
    a7 0f      ← [7] equalityMatch filter
      04 03 75 69 64   ← attributeDesc: &quot;uid&quot;
      04 06 76 61 6d   ← assertionValue: &quot;vamshi&quot;
             73 68 69
    30 05      ← SEQUENCE: AttributeDescriptionList
      04 03 75 69 64   ← &quot;uid&quot;
</code></pre>
<p>You don&#8217;t need to read BER by hand in practice. But knowing it&#8217;s binary — not HTTP, not JSON, not plain text — explains some things:</p>
<ul>
<li>Why <code class="" data-line="">tcpdump port 389</code> shows binary output you can&#8217;t read directly</li>
<li>Why LDAP on port 389 looks different in Wireshark than HTTP traffic</li>
<li>Why <code class="" data-line="">ldapsearch</code> output (LDIF) is a transformation of the wire data, not the wire data itself</li>
</ul>
<p>To see the wire protocol in action:</p>
<pre><code class="" data-line=""># Run ldapsearch with debug output (level 1 = protocol tracing)
ldapsearch -d 1 -x \
  -H ldap://ldap.forumsys.com \
  -b &quot;dc=example,dc=com&quot; \
  -D &quot;cn=read-only-admin,dc=example,dc=com&quot; \
  -w readonly \
  &quot;(uid=tesla)&quot; cn

# You&#039;ll see output like:
# ldap_connect_to_host: TCP ldap.forumsys.com:389
# ldap_new_connection 1 1 0
# ldap_connect_to_host: Trying ldap.forumsys.com:389
# ldap_pvt_connect: fd: 5 tm: -1 async: 0
# TLS: can&#039;t connect.
# ldap_open_defconn: successful
# ber_scanf fmt ({it) ber:     ← BER decoding of the response
# ber_scanf fmt ({) ber:
# ber_scanf fmt (W) ber:
# ...
</code></pre>
<p>The <code class="" data-line="">ber_scanf</code> lines are the BER decoder working through the server&#8217;s response. Each line represents one TLV element being read off the wire.</p>
<hr />
<h2 id="reading-ldapsearch-output-every-field">Reading ldapsearch Output: Every Field</h2>
<p><code class="" data-line="">ldapsearch</code> output is LDIF (LDAP Data Interchange Format), defined in RFC 2849. It&#8217;s the standard text serialization of LDAP entries.</p>
<pre><code class="" data-line="">ldapsearch -x \
  -H ldap://ldap.forumsys.com \
  -b &quot;dc=example,dc=com&quot; \
  -D &quot;cn=read-only-admin,dc=example,dc=com&quot; \
  -w readonly \
  &quot;(uid=tesla)&quot; \
  cn mail uid uidNumber objectClass
</code></pre>
<p>Output, annotated:</p>
<pre><code class="" data-line=""># extended LDIF
#
# LDAPv3                              ← protocol version confirmed
# base &lt;dc=example,dc=com&gt; with scope subtree
# filter: (uid=tesla)                 ← your search filter echoed back
# requesting: cn mail uid uidNumber objectClass
#

# tesla, example.com                  ← comment: CN, base DN
dn: uid=tesla,dc=example,dc=com      ← Distinguished Name — full path in the tree

objectClass: inetOrgPerson           ← structural class: person with org attrs
objectClass: organizationalPerson    ← auxiliary: adds telephoneNumber etc.
objectClass: person                  ← auxiliary: adds sn (surname)
objectClass: top                     ← every entry has this implicitly
cn: Tesla                            ← common name (from inetOrgPerson MUST)
mail: tesla@ldap.forumsys.com        ← email (from inetOrgPerson MAY)
uid: tesla                           ← userid (from inetOrgPerson MAY)

# search result
search: 2                            ← messageID of the SearchResultDone
result: 0 Success                    ← 0 = no error; 32 = no such object; 49 = invalid credentials

# numResponses: 2                    ← 1 result entry + 1 SearchResultDone
# numEntries: 1
</code></pre>
<p>The <code class="" data-line="">result:</code> line is the one to watch when debugging. LDAP result codes:</p>
<table>
<thead>
<tr>
<th>Code</th>
<th>Meaning</th>
<th>What it tells you</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>Success</td>
<td>Query ran, results returned (or no results found — check numEntries)</td>
</tr>
<tr>
<td>32</td>
<td>No Such Object</td>
<td>Base DN doesn&#8217;t exist in this directory</td>
</tr>
<tr>
<td>49</td>
<td>Invalid Credentials</td>
<td>Bind failed — wrong DN, wrong password, or account locked</td>
</tr>
<tr>
<td>50</td>
<td>Insufficient Access</td>
<td>Your bind DN doesn&#8217;t have read permission on these entries</td>
</tr>
<tr>
<td>53</td>
<td>Unwilling to Perform</td>
<td>Server refused the operation (e.g., password policy, anonymous bind disabled)</td>
</tr>
<tr>
<td>65</td>
<td>Object Class Violation</td>
<td>Add/Modify would violate schema (missing MUST attribute, unrecognized object class)</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="ports-389-636-and-3268">Ports: 389, 636, and 3268</h2>
<pre><code class="" data-line="">Port 389   — LDAP (plaintext, or StartTLS in-session upgrade)
Port 636   — LDAPS (LDAP wrapped in TLS from the start)
Port 3268  — Active Directory Global Catalog (plain)
Port 3269  — Active Directory Global Catalog over TLS
</code></pre>
<p><strong>Port 389 vs 636:</strong> Both carry the same BER-encoded LDAP protocol. The difference is when TLS starts. On 636 (LDAPS), the TLS handshake happens before the first LDAP message. On 389 with StartTLS, the client sends a plaintext <code class="" data-line="">ExtendedRequest</code> with OID <code class="" data-line="">1.3.6.1.4.1.1466.20037</code> to initiate the TLS upgrade, then both sides continue over TLS. In production, use one or the other — never unencrypted port 389. Your credentials transit the wire on every Bind.</p>
<p><strong>Ports 3268/3269 — Active Directory Global Catalog:</strong> AD organizes domains into forests. Each domain controller holds the full LDAP tree for its own domain. The Global Catalog is a read-only, partial replica of every domain in the forest — just the most-queried attributes from every object. When an application needs to find a user across domains in the same forest (not just in one domain), it queries the Global Catalog on 3268/3269 instead of a domain-specific DC on 389/636.</p>
<pre><code class="" data-line="">Forest: corp.com
  ├── Domain: corp.com       → DC at port 389/636   (full copy of corp.com)
  ├── Domain: emea.corp.com  → DC at port 389/636   (full copy of emea.corp.com)
  └── Global Catalog        → GC at port 3268/3269  (partial copy of ALL domains)
</code></pre>
<p>If your SSSD or application is configured to use port 3268 instead of 389, it&#8217;s talking to the Global Catalog — useful for forest-wide user lookups, but missing some less-common attributes that aren&#8217;t replicated to the GC.</p>
<hr />
<h2 id="try-it-ldapsearch-against-your-own-directory">Try It: ldapsearch Against Your Own Directory</h2>
<p>If your Linux machine is joined to AD or connected to an LDAP directory, you can run these right now:</p>
<pre><code class="" data-line=""># 1. Confirm your SSSD knows where the LDAP server is
grep -E &quot;ldap_uri|ad_domain|krb5_server&quot; /etc/sssd/sssd.conf

# 2. Look up your own user entry
ldapsearch -x \
  -H ldap://$(grep ldap_uri /etc/sssd/sssd.conf | awk -F= &#039;{print $2}&#039; | tr -d &#039; &#039;) \
  -b &quot;dc=$(hostname -d | sed &#039;s/\./,dc=/g&#039;)&quot; \
  &quot;(uid=$(whoami))&quot; \
  dn objectClass uid uidNumber gidNumber homeDirectory loginShell

# 3. Find the groups you&#039;re in
ldapsearch -x \
  -H ldap://your-dc \
  -b &quot;dc=corp,dc=com&quot; \
  &quot;(member=$(ldapsearch -x ... &quot;(uid=$(whoami))&quot; dn | grep ^dn | cut -d&#039; &#039; -f2-))&quot; \
  cn gidNumber

# 4. Check what object classes your entry has
ldapsearch -x \
  -H ldap://your-dc \
  -b &quot;dc=corp,dc=com&quot; \
  &quot;(uid=$(whoami))&quot; \
  objectClass
</code></pre>
<p>On a machine joined to Active Directory, the <code class="" data-line="">ldap_uri</code> in sssd.conf is your domain controller&#8217;s address. On FreeIPA or OpenLDAP, it&#8217;s the directory server. The same <code class="" data-line="">ldapsearch</code> commands work against all of them — because they all speak LDAP v3.</p>
<hr />
<h2 id="common-misconceptions"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Common Misconceptions</h2>
<p><strong>&#8220;The DN is like a file path.&#8221;</strong> The analogy holds for reading it, but the DIT is not a file system. Entries don&#8217;t inherit permissions from parent containers the way files inherit from directories. Access control in LDAP is defined by ACLs on the server — not by position in the tree.</p>
<p><strong>&#8220;LDAP is case-sensitive.&#8221;</strong> It depends on the attribute. Most string attributes (like <code class="" data-line="">cn</code> and <code class="" data-line="">mail</code>) use case-insensitive matching by default — <code class="" data-line="">(cn=Vamshi)</code> and <code class="" data-line="">(cn=vamshi)</code> return the same results. But some attributes (like <code class="" data-line="">userPassword</code> and most binary types) are case-sensitive. The schema&#8217;s matching rules define this per-attribute.</p>
<p><strong>&#8220;You need the full DN to search for a user.&#8221;</strong> No. The <code class="" data-line="">Search</code> operation with a <code class="" data-line="">sub</code> scope searches the entire subtree below the base DN. You search with a filter like <code class="" data-line="">(uid=vamshi)</code> without knowing the full DN. The DN comes back in the result.</p>
<p><strong>&#8220;LDAP accounts and Linux accounts are the same thing.&#8221;</strong> An LDAP user entry becomes a Linux account only if the entry has a <code class="" data-line="">posixAccount</code> object class with the required POSIX attributes (<code class="" data-line="">uidNumber</code>, <code class="" data-line="">gidNumber</code>, <code class="" data-line="">homeDirectory</code>). An LDAP entry without <code class="" data-line="">posixAccount</code> can exist in the directory but <code class="" data-line="">getent passwd</code> will not return it.</p>
<p><strong>&#8220;The objectClass attribute can be changed freely.&#8221;</strong> Structural object classes cannot be changed after an entry is created — you&#8217;d have to delete and recreate the entry. Auxiliary classes can be added or removed. This is why correctly choosing the structural class at entry creation time matters.</p>
<hr />
<h2 id="framework-alignment">Framework Alignment</h2>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Relevance</th>
</tr>
</thead>
<tbody>
<tr>
<td>CISSP Domain 5: Identity and Access Management</td>
<td>DIT structure, DN addressing, object classes, and schema are the data model underpinning every enterprise identity store — understanding them is foundational to managing directory-based IAM</td>
</tr>
<tr>
<td>CISSP Domain 4: Communications and Network Security</td>
<td>BER on port 389 is unencrypted; LDAPS (port 636) or StartTLS is required for production — wire-level understanding informs the transport security decision</td>
</tr>
<tr>
<td>CISSP Domain 3: Security Architecture and Engineering</td>
<td>Schema design and DIT hierarchy are architectural decisions with security consequences: overly permissive schemas enable privilege escalation; flat DITs make access delegation harder</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li>The DIT is a hierarchical database — every entry has a unique DN that describes its path from leaf to root</li>
<li>Object classes define the schema rules for each entry: what attributes are required (<code class="" data-line="">MUST</code>) vs optional (<code class="" data-line="">MAY</code>), and what the entry fundamentally is</li>
<li>For a user to be usable for Linux logins, the directory entry needs the <code class="" data-line="">posixAccount</code> object class with <code class="" data-line="">uidNumber</code>, <code class="" data-line="">gidNumber</code>, and <code class="" data-line="">homeDirectory</code> populated</li>
<li>An LDAP login is two operations: a Bind (authenticate), then a Search (retrieve POSIX attributes and group memberships)</li>
<li>Everything on the wire is BER-encoded binary — <code class="" data-line="">ldapsearch</code> output is LDIF, a human-readable transformation of what the wire actually carries</li>
<li>LDAP result code 0 means success; 49 means bad credentials; 32 means the base DN doesn&#8217;t exist — these are the three you&#8217;ll debug most often</li>
</ul>
<hr />
<hr />
<p>Run <code class="" data-line="">ldapsearch</code> against your own directory and look at the object classes on your entry. Does it have <code class="" data-line="">posixAccount</code>? Does it have <code class="" data-line="">shadowAccount</code>? What attributes is your SSSD actually reading on every login — and what does it do when the LDAP server is unreachable? <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<hr />
<h2 id="whats-next">What&#8217;s Next</h2>
<p>EP02 showed what&#8217;s inside the directory: the tree structure, the schema, the operations, and the wire protocol. What it left open is how Linux actually uses this information to grant a login.</p>
<p>LDAP is not, by itself, an authentication protocol. The Bind operation can verify a password — but that&#8217;s a tiny piece of what happens when you SSH into a machine joined to Active Directory. The full login flow runs through PAM, NSS, and SSSD before LDAP ever gets queried. EP03 traces that path.</p>
<p><em>Next: <a href="/ldap-authentication-linux-pam-nss/">LDAP Authentication on Linux: PAM, NSS, and the Login Stack</a></em></p>
<p>Get EP03 in your inbox when it publishes → <a href="https://linuxcent.com/subscribe">linuxcent.com/subscribe</a></p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-internals-directory-structure%2F&amp;linkname=LDAP%20Internals%3A%20The%20Directory%20Tree%2C%20Schema%2C%20and%20What%20Travels%20on%20the%20Wire" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-internals-directory-structure%2F&amp;linkname=LDAP%20Internals%3A%20The%20Directory%20Tree%2C%20Schema%2C%20and%20What%20Travels%20on%20the%20Wire" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-internals-directory-structure%2F&amp;linkname=LDAP%20Internals%3A%20The%20Directory%20Tree%2C%20Schema%2C%20and%20What%20Travels%20on%20the%20Wire" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-internals-directory-structure%2F&amp;linkname=LDAP%20Internals%3A%20The%20Directory%20Tree%2C%20Schema%2C%20and%20What%20Travels%20on%20the%20Wire" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-internals-directory-structure%2F&amp;linkname=LDAP%20Internals%3A%20The%20Directory%20Tree%2C%20Schema%2C%20and%20What%20Travels%20on%20the%20Wire" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-internals-directory-structure%2F&amp;linkname=LDAP%20Internals%3A%20The%20Directory%20Tree%2C%20Schema%2C%20and%20What%20Travels%20on%20the%20Wire" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fldap-internals-directory-structure%2F&amp;linkname=LDAP%20Internals%3A%20The%20Directory%20Tree%2C%20Schema%2C%20and%20What%20Travels%20on%20the%20Wire" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fldap-internals-directory-structure%2F&#038;title=LDAP%20Internals%3A%20The%20Directory%20Tree%2C%20Schema%2C%20and%20What%20Travels%20on%20the%20Wire" data-a2a-url="https://linuxcent.com/ldap-internals-directory-structure/" data-a2a-title="LDAP Internals: The Directory Tree, Schema, and What Travels on the Wire"></a></p><p>The post <a href="https://linuxcent.com/ldap-internals-directory-structure/">LDAP Internals: The Directory Tree, Schema, and What Travels on the Wire</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/ldap-internals-directory-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1771</post-id>	</item>
		<item>
		<title>What Is LDAP — and Why It Was Invented to Replace Something Worse</title>
		<link>https://linuxcent.com/what-is-ldap/</link>
					<comments>https://linuxcent.com/what-is-ldap/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Fri, 24 Apr 2026 04:43:19 +0000</pubDate>
				<category><![CDATA[Identity & Authentication]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Directory Services]]></category>
		<category><![CDATA[Enterprise IT]]></category>
		<category><![CDATA[Identity Management]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux-security]]></category>
		<guid isPermaLink="false">https://linuxcent.com/what-is-ldap/</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 9</span> <span class="rt-label rt-postfix">minutes</span></span>LDAP solved 1980s authentication chaos and still powers enterprise logins today. Learn what it replaced, how it works, and why it's still in your stack.</p>
<p>The post <a href="https://linuxcent.com/what-is-ldap/">What Is LDAP — and Why It Was Invented to Replace Something Worse</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 9</span> <span class="rt-label rt-postfix">minutes</span></span><style>
pre{position:relative;background:#1e1e1e;color:#d4d4d4;
    padding:16px 16px 16px 20px;border-radius:6px;overflow-x:auto;
    font-family:'JetBrains Mono','Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
    font-size:.88em;line-height:1.6;border-left:4px solid #555}
code{background:#f4f4f4;padding:2px 5px;border-radius:3px;font-size:.9em}
pre code{background:transparent;padding:0;color:inherit}
pre[data-lang="bash"],pre[data-lang="sh"],
pre[data-lang="shell"],pre[data-lang="zsh"]{border-left-color:#4ec9b0}
pre[data-lang="yaml"],pre[data-lang="json"],
pre[data-lang="toml"],pre[data-lang="xml"]{border-left-color:#569cd6}
pre[data-lang="python"],pre[data-lang="go"],pre[data-lang="rust"],
pre[data-lang="java"],pre[data-lang="c"],pre[data-lang="cpp"]{border-left-color:#c586c0}
pre[data-lang="text"],pre[data-lang="output"],
pre[data-lang="console"]{border-left-color:#888}
.lc-copy-btn{position:absolute;top:8px;right:8px;background:#2d2d2d;color:#ccc;
    border:1px solid #444;border-radius:4px;padding:3px 9px;font-size:.75em;
    font-family:system-ui,sans-serif;cursor:pointer;opacity:0;
    transition:opacity .15s,background .15s;line-height:1.6}
pre:hover .lc-copy-btn{opacity:1}
.lc-copy-btn:hover{background:#3a3a3a;color:#fff}
.lc-copy-btn.copied{color:#4ec9b0;border-color:#4ec9b0}
.lc-lang-badge{position:absolute;top:8px;left:20px;font-family:system-ui,sans-serif;
    font-size:.7em;color:#666;text-transform:uppercase;letter-spacing:.04em;
    line-height:1;pointer-events:none;opacity:0;transition:opacity .15s}
pre:hover .lc-lang-badge{opacity:1}
table{border-collapse:collapse;width:100%;margin:16px 0}
th,td{border:1px solid #ddd;padding:10px 14px;text-align:left}
th{background:#f0f0f0;font-weight:600}
tr:nth-child(even){background:#fafafa}
</style>
<p><script>
(function(){
  if(window.__lcCodeEnhanced)return;
  window.__lcCodeEnhanced=true;
  function enhance(){
    document.querySelectorAll('pre').forEach(function(pre){
      var code=pre.querySelector('code');
      var lang='';
      if(code){var m=(code.className||'').match(/language-(\S+)/);if(m)lang=m[1].toLowerCase();}
      if(lang)pre.setAttribute('data-lang',lang);
      if(lang){var badge=document.createElement('span');badge.className='lc-lang-badge';badge.textContent=lang;pre.insertBefore(badge,pre.firstChild);}
      var btn=document.createElement('button');
      btn.className='lc-copy-btn';btn.textContent='Copy';btn.setAttribute('aria-label','Copy code to clipboard');
      pre.appendChild(btn);
      btn.addEventListener('click',function(){
        var text=code?code.innerText:pre.innerText;
        if(navigator.clipboard&&window.isSecureContext){
          navigator.clipboard.writeText(text).then(function(){ok(btn);}).catch(function(){fb(text,btn);});
        }else{fb(text,btn);}
      });
    });
  }
  function ok(btn){btn.textContent='Copied!';btn.classList.add('copied');setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied');},2000);}
  function fb(text,btn){
    try{var ta=document.createElement('textarea');ta.value=text;ta.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);ok(btn);}
    catch(e){btn.textContent='✗ Failed';setTimeout(function(){btn.textContent='Copy';},2000);}
  }
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',enhance);}else{enhance();}
})();
</script></p>
<p><em>The Identity Stack, Episode 1</em><br />
<strong>EP01</strong> → <a href="/ldap-internals-directory-structure/">EP02: LDAP Internals</a> → EP03 → &#8230;</p>
<hr />
<h2 id="tldr">TL;DR</h2>
<ul>
<li>LDAP (Lightweight Directory Access Protocol) is a protocol for reading and writing directory information — most commonly, who is allowed to do what</li>
<li>It was built in 1993 as a &#8220;lightweight&#8221; alternative to X.500/DAP, which ran over the full OSI stack and was impossible to deploy on anything but mainframe hardware</li>
<li>Before LDAP, every server had its own <code class="" data-line="">/etc/passwd</code> — 50 machines meant 50 separate user databases, managed manually</li>
<li>NIS (Network Information Service) was the first attempt to centralize this — it worked, then became a cleartext-credentials security liability</li>
<li>LDAP v3 (RFC 2251, 1997) is the version still in production today — 27 years of backwards compatibility</li>
<li>Everything you use today — Active Directory, Okta, Entra ID — is built on top of, or speaks, LDAP</li>
</ul>
<hr />
<h2 id="the-big-picture-50-years-of-who-are-you">The Big Picture: 50 Years of &#8220;Who Are You?&#8221;</h2>
<pre><code class="" data-line="">1969–1980s   /etc/passwd — per-machine, no network auth
     │        50 servers = 50 user databases, managed manually
     │
     ▼
1984         Sun NIS / Yellow Pages — first centralized directory
     │        broadcast-based, no encryption, flat namespace
     │        Revolutionary for its era. A liability by the 1990s.
     │
     ▼
1988         X.500 / DAP — enterprise-grade directory services
     │        OSI protocol stack. Powerful. Impossible to deploy.
     │        Mainframe-class infrastructure required just to run it.
     │
     ▼
1993         RFC 1487 — LDAP v1
     │        Tim Howes, University of Michigan.
     │        Lightweight. TCP/IP. Actually deployable.
     │
     ▼
1997         RFC 2251 — LDAP v3
     │        SASL authentication. TLS. Controls. Referrals.
     │        The version still in production today.
     │
     ▼
2000s–now    Active Directory, OpenLDAP, 389-DS, FreeIPA
             Okta, Entra ID, Google Workspace
             LDAP DNA in every identity system on the planet.
</code></pre>
<p>What is LDAP? It&#8217;s the protocol that solved one of the most boring and consequential problems in computing: how do you know who someone is, across machines, at scale, without sending their password in cleartext?</p>
<hr />
<h2 id="the-world-before-ldap">The World Before LDAP</h2>
<p>Before you understand why LDAP was invented, you need to feel the problem it solved.</p>
<p>Every Unix machine in the 1970s and 1980s managed its own users. When you created an account on a server, your username, UID, and hashed password went into <code class="" data-line="">/etc/passwd</code> on that machine. Another machine had no idea you existed. If you needed access to ten servers, an administrator created ten separate accounts — manually, one by one. When you changed your password, each account had to be updated separately.</p>
<p>For a university with 200 machines and 10,000 students, this was chaos. For a company with offices in three cities, it was a full-time job for multiple sysadmins.</p>
<pre><code class="" data-line="">Machine A           Machine B           Machine C
/etc/passwd         /etc/passwd         /etc/passwd
vamshi:x:1001       (vamshi unknown)    vamshi:x:1004
alice:x:1002        alice:x:1001        alice:x:1003
bob:x:1003          bob:x:1002          (bob unknown)

Same people, different UIDs, different machines, no central truth.
File permissions become meaningless when UID 1001 means
different users on different hosts.
</code></pre>
<p>For every new hire, an admin SSHed to every machine and ran <code class="" data-line="">useradd</code>. When someone left, you hoped whoever ran the offboarding remembered all the machines. Most organizations didn&#8217;t know their own attack surface because there was no single place to look.</p>
<hr />
<h3 id="sun-nis-the-first-attempt-at-centralization">Sun NIS: The First Attempt at Centralization</h3>
<p>Sun Microsystems released NIS (Network Information Service) in 1984, originally called Yellow Pages — a name they had to drop after a trademark dispute with British Telecom. The idea was elegant: one server holds the authoritative <code class="" data-line="">/etc/passwd</code> (and <code class="" data-line="">/etc/group</code>, <code class="" data-line="">/etc/hosts</code>, and a dozen other maps), and client machines query it instead of reading local files.</p>
<p>For the first time, you could create an account once and have it work across your entire network. For a generation of Unix administrators, NIS was liberating.</p>
<pre><code class="" data-line="">       NIS Master Server
       /var/yp/passwd.byname
              │
    ┌─────────┼──────────┐
    ▼         ▼          ▼
 Client A   Client B   Client C
 (query NIS — no local /etc/passwd needed)
</code></pre>
<p>NIS worked well — until it didn&#8217;t. The failure modes were structural:</p>
<p><strong>No encryption.</strong> NIS responses were cleartext UDP. An attacker on the same network segment could capture the full password database with a packet sniffer. In 1984, &#8220;the network&#8221; meant a trusted corporate LAN. By the mid-1990s, it meant ethernet segments that included lab workstations, and the assumptions no longer held.</p>
<p><strong>Broadcast-based discovery.</strong> NIS clients found servers by broadcasting on the local network. This worked on a single flat ethernet. It failed completely across routers, across buildings, and across WAN links. Multi-site organizations ended up running separate NIS domains with no connection between them — which partially defeated the purpose.</p>
<p><strong>Flat namespace.</strong> NIS had no organizational hierarchy. One domain. Everything flat. You couldn&#8217;t have <code class="" data-line="">engineering</code> and <code class="" data-line="">finance</code> as separate administrative units. You couldn&#8217;t delegate user management to a department. One person — usually one overworked sysadmin — managed the whole thing.</p>
<p><strong>UIDs had to match across all machines.</strong> If <code class="" data-line="">alice</code> was UID 1002 on one server but UID 1001 on another, NFS file ownership became wrong. NIS enforced consistency, but onboarding a new machine into an existing network required manually auditing UID conflicts across the entire directory. Get one wrong and files end up owned by the wrong person.</p>
<p>NIS worked for thousands of installations from 1984 to the mid-1990s. It also ended careers when it failed. What the industry needed was a hierarchical, structured, encrypted, scalable directory service.</p>
<hr />
<h2 id="x500-and-dap-the-right-idea-wrong-protocol">X.500 and DAP: The Right Idea, Wrong Protocol</h2>
<p>The OSI (Open Systems Interconnection) standards body had an answer: X.500 directory services. X.500 was comprehensive, hierarchical, globally federated. The ITU-T published the standard in 1988, and it looked like exactly what enterprises needed.</p>
<pre><code class="" data-line="">X.500 Directory Information Tree (DIT)
              c=US                   ← country
                │
         o=University                ← organization
                │
         ┌──────┴──────┐
     ou=CS           ou=Physics      ← organizational units
         │
     cn=Tim Howes                    ← common name (person)
     telephoneNumber: +1-734-...
     mail: tim@umich.edu
</code></pre>
<p>This data model — the hierarchy, the object classes, the distinguished names — is exactly what LDAP inherited. The DIT, the <code class="" data-line="">cn=</code>, <code class="" data-line="">ou=</code>, <code class="" data-line="">dc=</code> notation in every LDAP query you&#8217;ve ever read: all of it came from X.500.</p>
<p>The problem was DAP: the Directory Access Protocol that X.500 used to communicate.</p>
<p>DAP ran over the full OSI protocol stack. Not TCP/IP — OSI. Seven layers, all of which required specialized software that in 1988 only mainframe and minicomputer vendors had implemented. A university department wanting to run X.500 needed hardware and software licenses that cost as much as a small car. The vast majority of workstations couldn&#8217;t speak OSI at all.</p>
<p>The data model was sound. The transport was impractical.</p>
<pre><code class="" data-line="">X.500 / DAP (1988)              LDAP v1 (1993)
──────────────────              ──────────────
Full OSI stack (7 layers)  →    TCP/IP only
Mainframe-class hardware   →    Any Unix box with a TCP stack
$50,000+ deployment cost   →    Free (reference implementation)
Vendor-specific OSI impl.  →    Standard socket API
Zero internet adoption     →    Universities deployed immediately
</code></pre>
<hr />
<h2 id="the-invention-ldap-at-the-university-of-michigan">The Invention: LDAP at the University of Michigan</h2>
<p>Tim Howes was at the University of Michigan in the early 1990s. The university was running X.500 for its directory — faculty, staff, student contact information, credentials. The data model was good. The protocol was the problem.</p>
<p>His insight, working with colleagues Wengyik Yeong and Steve Kille: strip X.500 down to what actually needs to function over a TCP/IP connection. Keep the hierarchical data model. Throw away the OSI transport. The result was the Lightweight Directory Access Protocol.</p>
<p>RFC 1487, published July 1993, described LDAP v1. It preserved the X.500 directory information model — the hierarchy, the object classes, the distinguished name format — and mapped it onto a protocol that could run over a simple TCP socket on port 389.</p>
<p>No specialized hardware. No OSI. If you had a Unix machine and TCP/IP, you could run LDAP. By 1993, that meant virtually every workstation and server in every university and most enterprises.</p>
<p>The University of Michigan deployed it immediately. Within two years, organizations across the internet were running the reference implementation.</p>
<p>LDAP v2 (RFC 1777, 1995) cleaned up the protocol. LDAP v3 (RFC 2251, 1997) is the version in production today — adding SASL authentication (which enables Kerberos integration), TLS support, referrals for federated directories, and extensible controls for server-side operations. The RFC that standardized the internet&#8217;s primary identity protocol is 27 years old and still running.</p>
<hr />
<h2 id="what-ldap-actually-is">What LDAP Actually Is</h2>
<p>LDAP is a client-server protocol for reading and writing a directory — a structured, hierarchical database optimized for reads.</p>
<p>Every entry in the directory has a Distinguished Name (DN) that describes its position in the hierarchy, and a set of attributes defined by its object classes. A person entry looks like this:</p>
<pre><code class="" data-line="">dn: cn=vamshi,ou=engineers,dc=linuxcent,dc=com

objectClass: inetOrgPerson
objectClass: posixAccount
cn: vamshi
uid: vamshi
uidNumber: 1001
gidNumber: 1001
homeDirectory: /home/vamshi
loginShell: /bin/bash
mail: vamshi@linuxcent.com
</code></pre>
<p>The DN reads right-to-left: domain <code class="" data-line="">linuxcent.com</code> (<code class="" data-line="">dc=linuxcent,dc=com</code>) → organizational unit <code class="" data-line="">engineers</code> → common name <code class="" data-line="">vamshi</code>. Every entry in the directory has a unique path through the tree — there&#8217;s no ambiguity about which <code class="" data-line="">vamshi</code> you mean.</p>
<p>LDAP defines eight operations: Bind (authenticate), Search, Add, Modify, Delete, ModifyDN (rename), Compare, and Abandon. Most of what a Linux authentication system does with LDAP reduces to two: <strong>Bind</strong> (prove you are who you say you are) and <strong>Search</strong> (tell me everything you know about this user).</p>
<p>When your Linux machine authenticates an SSH login against LDAP:</p>
<pre><code class="" data-line="">1. User types password
2. PAM calls pam_sss (or pam_ldap on older systems)
3. SSSD issues a Bind to the LDAP server: &quot;I am cn=vamshi, and here is my credential&quot;
4. LDAP server verifies the bind → success or failure
5. SSSD issues a Search: &quot;give me the posixAccount attributes for uid=vamshi&quot;
6. LDAP returns uidNumber, gidNumber, homeDirectory, loginShell
7. PAM creates the session with those attributes
</code></pre>
<p>The entire login flow is two LDAP operations: one Bind, one Search.</p>
<hr />
<h2 id="try-it-right-now">Try It Right Now</h2>
<p>You don&#8217;t need to set up an LDAP server to run your first query. There&#8217;s a public test LDAP directory at <code class="" data-line="">ldap.forumsys.com</code>:</p>
<pre><code class="" data-line=""># Query a public LDAP server — no setup required
ldapsearch -x \
  -H ldap://ldap.forumsys.com \
  -b &quot;dc=example,dc=com&quot; \
  -D &quot;cn=read-only-admin,dc=example,dc=com&quot; \
  -w readonly \
  &quot;(objectClass=inetOrgPerson)&quot; \
  cn mail uid

# What you get back (abbreviated):
# dn: uid=tesla,dc=example,dc=com
# cn: Tesla
# mail: tesla@ldap.forumsys.com
# uid: tesla
#
# dn: uid=einstein,dc=example,dc=com
# cn: Albert Einstein
# mail: einstein@ldap.forumsys.com
# uid: einstein
</code></pre>
<p>Decode what you just ran:</p>
<ul>
<li><code class="" data-line="">-x</code> — simple authentication (username/password bind, not Kerberos/SASL)</li>
<li><code class="" data-line="">-H ldap://ldap.forumsys.com</code> — the LDAP server URI, port 389</li>
<li><code class="" data-line="">-b &quot;dc=example,dc=com&quot;</code> — the base DN, the top of the subtree to search</li>
<li><code class="" data-line="">-D &quot;cn=read-only-admin,dc=example,dc=com&quot;</code> — the bind DN (who you&#8217;re authenticating as)</li>
<li><code class="" data-line="">-w readonly</code> — the bind password</li>
<li><code class="" data-line="">&quot;(objectClass=inetOrgPerson)&quot;</code> — the search filter: return entries that are people</li>
<li><code class="" data-line="">cn mail uid</code> — the attributes to return (default returns all)</li>
</ul>
<p>That&#8217;s a live LDAP query returning real directory entries from a server running RFC 2251 — the same protocol Tim Howes designed in 1993.</p>
<p>On your own Linux system, if you&#8217;re joined to AD or LDAP, you can query it the same way with your domain credentials.</p>
<hr />
<h2 id="why-it-never-went-away">Why It Never Went Away</h2>
<p>LDAP v3 was finalized in 1997. In 2024, it&#8217;s still the protocol every enterprise directory speaks. Why?</p>
<p>Because it became the lingua franca of enterprise identity before any replacement existed. Every application that needs to authenticate users — VPN concentrators, mail servers, network switches, web applications, HR systems — implemented LDAP support. Every directory service Microsoft, Red Hat, Sun, and Novell shipped stored data in an LDAP-accessible tree.</p>
<p>When Microsoft built Active Directory in 1999, they built it on top of LDAP + Kerberos. When your Linux machine joins an AD domain, it speaks LDAP to enumerate users and groups, and Kerberos to verify credentials. When Okta or Entra ID syncs with your on-premises directory, it uses LDAP Sync (or a modern protocol that maps directly to LDAP semantics).</p>
<p>The protocol is old. The ecosystem built on top of it is so deep that replacing LDAP would mean simultaneously replacing every enterprise application that depends on it. Nobody has done that. Nobody has had to.</p>
<p>What happened instead is the stack got taller. LDAP at the bottom, Kerberos for network authentication, SSSD as the local caching daemon, PAM as the Linux integration layer, SAML and OIDC at the top for web-based federation. The directory is still LDAP. The interfaces above it evolved.</p>
<p>That full stack — from the directory at the bottom to Zero Trust at the top — is what this series covers.</p>
<hr />
<h2 id="common-misconceptions"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Common Misconceptions</h2>
<p><strong>&#8220;LDAP is an authentication protocol.&#8221;</strong> LDAP is a directory protocol. It stores identity information and can verify credentials (via Bind). Authentication in modern stacks is typically Kerberos or OIDC — LDAP provides the directory backing it.</p>
<p><strong>&#8220;LDAP is obsolete.&#8221;</strong> LDAP is the storage layer for Active Directory, OpenLDAP, 389-DS, FreeIPA, and every enterprise IdP&#8217;s on-premises sync. It is ubiquitous. What&#8217;s changed is the interface layer above it.</p>
<p><strong>&#8220;You need Active Directory to run LDAP.&#8221;</strong> Active Directory uses LDAP. OpenLDAP, 389-DS, FreeIPA, and Apache Directory Server are all standalone LDAP implementations. You can run a directory without Microsoft.</p>
<p><strong>&#8220;LDAP and LDAPS are different protocols.&#8221;</strong> LDAP is the protocol. LDAPS is LDAP over TLS on port 636. StartTLS is LDAP on port 389 with an in-session upgrade to TLS. Same protocol, different transport security.</p>
<hr />
<h2 id="framework-alignment">Framework Alignment</h2>
<table>
<thead>
<tr>
<th>Domain</th>
<th>Relevance</th>
</tr>
</thead>
<tbody>
<tr>
<td>CISSP Domain 5: Identity and Access Management</td>
<td>LDAP is the foundational directory protocol for centralized identity stores — the base layer of every enterprise IAM stack</td>
</tr>
<tr>
<td>CISSP Domain 4: Communications and Network Security</td>
<td>Port 389 (LDAP), 636 (LDAPS), 3268/3269 (AD Global Catalog) — transport security decisions affect every directory deployment</td>
</tr>
<tr>
<td>CISSP Domain 3: Security Architecture and Engineering</td>
<td>DIT hierarchy, schema design, replication topology — directory structure is an architectural security decision</td>
</tr>
<tr>
<td>NIST SP 800-63B</td>
<td>LDAP as a credential service provider (CSP) backing enterprise authenticators</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li>LDAP was invented to solve a real, painful problem: the authentication chaos that NIS couldn&#8217;t fix and X.500/DAP was too expensive to deploy</li>
<li>It inherited the right thing from X.500 (the hierarchical data model) and replaced the right thing (the impractical OSI transport with TCP/IP)</li>
<li>NIS was the predecessor that worked until it didn&#8217;t — its failure modes (no encryption, flat namespace, broadcast discovery) are exactly what LDAP was designed to fix</li>
<li>LDAP v3 (RFC 2251, 1997) is still the production standard — 27 years later</li>
<li>Active Directory, OpenLDAP, FreeIPA, Okta, Entra ID — every enterprise identity system either runs LDAP or speaks it</li>
<li>The full authentication stack is deeper than LDAP: the next 12 episodes peel it apart layer by layer</li>
</ul>
<hr />
<h2 id="whats-next">What&#8217;s Next</h2>
<p>EP01 stayed at the design level — the problem, the predecessor failures, the invention, the data model.</p>
<p>EP02 goes inside the wire. The DIT structure, DN syntax, object classes, schema, and the BER-encoded bytes that actually travel from the server to your authentication daemon. Run <code class="" data-line="">ldapsearch</code> against your own directory and read every line of what comes back.</p>
<p><em>Next: <a href="/ldap-internals-directory-structure/">LDAP Internals: The Directory Tree, Schema, and What Travels on the Wire</a></em></p>
<p>Get EP02 in your inbox when it publishes → <a href="https://linuxcent.com/subscribe">linuxcent.com/subscribe</a></p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fwhat-is-ldap%2F&amp;linkname=What%20Is%20LDAP%20%E2%80%94%20and%20Why%20It%20Was%20Invented%20to%20Replace%20Something%20Worse" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fwhat-is-ldap%2F&amp;linkname=What%20Is%20LDAP%20%E2%80%94%20and%20Why%20It%20Was%20Invented%20to%20Replace%20Something%20Worse" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fwhat-is-ldap%2F&amp;linkname=What%20Is%20LDAP%20%E2%80%94%20and%20Why%20It%20Was%20Invented%20to%20Replace%20Something%20Worse" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fwhat-is-ldap%2F&amp;linkname=What%20Is%20LDAP%20%E2%80%94%20and%20Why%20It%20Was%20Invented%20to%20Replace%20Something%20Worse" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fwhat-is-ldap%2F&amp;linkname=What%20Is%20LDAP%20%E2%80%94%20and%20Why%20It%20Was%20Invented%20to%20Replace%20Something%20Worse" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fwhat-is-ldap%2F&amp;linkname=What%20Is%20LDAP%20%E2%80%94%20and%20Why%20It%20Was%20Invented%20to%20Replace%20Something%20Worse" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fwhat-is-ldap%2F&amp;linkname=What%20Is%20LDAP%20%E2%80%94%20and%20Why%20It%20Was%20Invented%20to%20Replace%20Something%20Worse" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fwhat-is-ldap%2F&#038;title=What%20Is%20LDAP%20%E2%80%94%20and%20Why%20It%20Was%20Invented%20to%20Replace%20Something%20Worse" data-a2a-url="https://linuxcent.com/what-is-ldap/" data-a2a-title="What Is LDAP — and Why It Was Invented to Replace Something Worse"></a></p><p>The post <a href="https://linuxcent.com/what-is-ldap/">What Is LDAP — and Why It Was Invented to Replace Something Worse</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/what-is-ldap/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1545</post-id>	</item>
		<item>
		<title>Authentication vs Authorization: AWS AccessDenied Explained</title>
		<link>https://linuxcent.com/authentication-vs-authorization-iam/</link>
					<comments>https://linuxcent.com/authentication-vs-authorization-iam/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Tue, 14 Apr 2026 05:05:02 +0000</pubDate>
				<category><![CDATA[Cloud IAM]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Cloud Security]]></category>
		<category><![CDATA[IAM]]></category>
		<category><![CDATA[Identity Management]]></category>
		<category><![CDATA[MFA]]></category>
		<category><![CDATA[OAuth2]]></category>
		<category><![CDATA[OIDC]]></category>
		<guid isPermaLink="false">https://linuxcent.com/authentication-vs-authorization-iam/</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 10</span> <span class="rt-label rt-postfix">minutes</span></span>Authentication proves identity. Authorization proves permission. Learn why confusing the two creates security gaps — and how cloud IAM implements both correctly.</p>
<p>The post <a href="https://linuxcent.com/authentication-vs-authorization-iam/">Authentication vs Authorization: AWS AccessDenied Explained</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 10</span> <span class="rt-label rt-postfix">minutes</span></span><style>
pre{position:relative;background:#1e1e1e;color:#d4d4d4;
    padding:16px 16px 16px 20px;border-radius:6px;overflow-x:auto;
    font-family:'JetBrains Mono','Fira Code','Cascadia Code',Consolas,'Courier New',monospace;
    font-size:.88em;line-height:1.6;border-left:4px solid #555}
code{background:#f4f4f4;padding:2px 5px;border-radius:3px;font-size:.9em}
pre code{background:transparent;padding:0;color:inherit}
pre[data-lang="bash"],pre[data-lang="sh"],
pre[data-lang="shell"],pre[data-lang="zsh"]{border-left-color:#4ec9b0}
pre[data-lang="yaml"],pre[data-lang="json"],
pre[data-lang="toml"],pre[data-lang="xml"]{border-left-color:#569cd6}
pre[data-lang="python"],pre[data-lang="go"],pre[data-lang="rust"],
pre[data-lang="java"],pre[data-lang="c"],pre[data-lang="cpp"]{border-left-color:#c586c0}
pre[data-lang="text"],pre[data-lang="output"],
pre[data-lang="console"]{border-left-color:#888}
.lc-copy-btn{position:absolute;top:8px;right:8px;background:#2d2d2d;color:#ccc;
    border:1px solid #444;border-radius:4px;padding:3px 9px;font-size:.75em;
    font-family:system-ui,sans-serif;cursor:pointer;opacity:0;
    transition:opacity .15s,background .15s;line-height:1.6}
pre:hover .lc-copy-btn{opacity:1}
.lc-copy-btn:hover{background:#3a3a3a;color:#fff}
.lc-copy-btn.copied{color:#4ec9b0;border-color:#4ec9b0}
.lc-lang-badge{position:absolute;top:8px;left:20px;font-family:system-ui,sans-serif;
    font-size:.7em;color:#666;text-transform:uppercase;letter-spacing:.04em;
    line-height:1;pointer-events:none;opacity:0;transition:opacity .15s}
pre:hover .lc-lang-badge{opacity:1}
table{border-collapse:collapse;width:100%;margin:16px 0}
th,td{border:1px solid #ddd;padding:10px 14px;text-align:left}
th{background:#f0f0f0;font-weight:600}
tr:nth-child(even){background:#fafafa}
</style>
<p><script>
(function(){
  if(window.__lcCodeEnhanced)return;
  window.__lcCodeEnhanced=true;
  function enhance(){
    document.querySelectorAll('pre').forEach(function(pre){
      var code=pre.querySelector('code');
      var lang='';
      if(code){var m=(code.className||'').match(/language-(\S+)/);if(m)lang=m[1].toLowerCase();}
      if(lang)pre.setAttribute('data-lang',lang);
      if(lang){var badge=document.createElement('span');badge.className='lc-lang-badge';badge.textContent=lang;pre.insertBefore(badge,pre.firstChild);}
      var btn=document.createElement('button');
      btn.className='lc-copy-btn';btn.textContent='Copy';btn.setAttribute('aria-label','Copy code to clipboard');
      pre.appendChild(btn);
      btn.addEventListener('click',function(){
        var text=code?code.innerText:pre.innerText;
        if(navigator.clipboard&&window.isSecureContext){
          navigator.clipboard.writeText(text).then(function(){ok(btn);}).catch(function(){fb(text,btn);});
        }else{fb(text,btn);}
      });
    });
  }
  function ok(btn){btn.textContent='Copied!';btn.classList.add('copied');setTimeout(function(){btn.textContent='Copy';btn.classList.remove('copied');},2000);}
  function fb(text,btn){
    try{var ta=document.createElement('textarea');ta.value=text;ta.style.cssText='position:fixed;left:-9999px;top:-9999px;opacity:0';document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);ok(btn);}
    catch(e){btn.textContent='✗ Failed';setTimeout(function(){btn.textContent='Copy';},2000);}
  }
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',enhance);}else{enhance();}
})();
</script></p>
<hr />
<p><a href="/what-is-cloud-iam/">What Is Cloud IAM</a> → <strong>Authentication vs Authorization</strong> → <a href="/iam-roles-policies-permissions-explained/">IAM Roles vs Policies</a> → <a href="/aws-iam-deep-dive/">AWS IAM Deep Dive</a> → <a href="/gcp-iam-deep-dive/">GCP Resource Hierarchy IAM</a> → <a href="/azure-rbac-entra-id-guide/">Azure RBAC Scopes</a></p>
<hr />
<h2 id="tldr">TL;DR</h2>
<ul>
<li>Authentication asks <em>are you who you claim to be?</em> Authorization asks <em>are you allowed to do this?</em> — two separate gates, two separate failure modes</li>
<li>AWS <code class="" data-line="">AccessDenied</code> is an <strong>authorization</strong> failure — the identity authenticated fine; fix the policy, not the credentials</li>
<li>Prefer short-lived credentials (STS temporary tokens, Managed Identities) over long-lived access keys — the difference is the blast radius window</li>
<li>MFA strengthens authentication; it does <strong>nothing</strong> for authorization — a hijacked session with broad permissions is just as dangerous with or without MFA on the original login</li>
<li><code class="" data-line="">HTTP 401</code> = authentication failure; <code class="" data-line="">HTTP 403</code> = authorization failure — the code tells you which gate to debug</li>
<li>Both layers must enforce least privilege independently — application-layer authorization is not a substitute for tight cloud IAM</li>
</ul>
<hr />
<h2 id="the-big-picture">The Big Picture</h2>
<p>Every API call in the cloud passes through two gates before it executes. Most engineers know the first one. The second is where most security failures live.</p>
<pre><code class="" data-line="">  THE TWO GATES — every cloud API call passes through both, in order

  ┌──────────────────────────────────────────────────────────────────┐
  │  GATE 1 — AUTHENTICATION                                         │
  │  &quot;Are you who you claim to be?&quot;                                  │
  │                                                                  │
  │  IAM user     →  Access Key + Secret (long-lived, rotatable)    │
  │  IAM role     →  Temporary STS token (expires automatically)    │
  │  Human        →  Password + MFA via console or IdP              │
  │  Service      →  Instance profile / Managed Identity / OIDC     │
  │                                                                  │
  │  Passes → move to Gate 2                                        │
  │  Fails  → stopped here, HTTP 401                                │
  └──────────────────────────────────────────────────────────────────┘
                                 │
                                 ▼
  ┌──────────────────────────────────────────────────────────────────┐
  │  GATE 2 — AUTHORIZATION                                          │
  │  &quot;Are you allowed to do what you&#039;re trying to do?&quot;               │
  │                                                                  │
  │  Evaluated against: identity-based policies · SCPs              │
  │                     resource-based policies · conditions         │
  │                     permissions boundaries · session policies    │
  │                                                                  │
  │  Default answer: DENY (explicit Allow required every time)      │
  │                                                                  │
  │  Passes → request executes                                      │
  │  Fails  → AccessDenied / HTTP 403                               │
  └──────────────────────────────────────────────────────────────────┘

  MFA hardens Gate 1. It has zero effect on Gate 2.
  A hijacked session with a valid token clears Gate 1 automatically.
  Gate 2 is your last line of defense — and the one that&#039;s most often misconfigured.
</code></pre>
<hr />
<h2 id="introduction">Introduction</h2>
<p>The authentication vs authorization distinction is the most commonly confused boundary in cloud security — and the source of most misdirected debugging when an AWS AccessDenied error appears. These are two separate gates, two separate failure modes, and two entirely different fixes.</p>
<p>Early in my career I wrote an API endpoint I was proud of. Token validation. Rejection of unauthenticated requests. I called it &#8220;secured&#8221; in the code review.</p>
<p>A senior engineer asked one question: &#8220;What happens if I take a valid token from a regular user and call your <code class="" data-line="">/admin/delete-user</code> endpoint?&#8221;</p>
<p>I ran the test. It worked. Any employee — with a perfectly valid, properly issued token — could delete any user account in the system.</p>
<p>The authentication was correct. The authorization didn&#8217;t exist.</p>
<p>That gap between <em>proving who you are</em> and <em>proving you&#8217;re allowed to do this</em> is where a surprising number of security incidents live. Not just in application code — in cloud IAM too.</p>
<p>I&#8217;ve reviewed AWS environments where MFA was enforced on every human account, access keys were rotated quarterly, and yet a Lambda function had <code class="" data-line="">s3:*</code> on <code class="" data-line="">*</code> because whoever wrote the deployment script reached for <code class="" data-line="">AmazonS3FullAccess</code> and moved on.</p>
<p>Gate 1 was solid. Gate 2 was wide open.</p>
<p>This episode draws the boundary cleanly — what each gate is, how each cloud implements it, and the specific failure modes that happen when the two get conflated.</p>
<hr />
<h2 id="how-authentication-works-in-cloud-iam">How Authentication Works in Cloud IAM</h2>
<p>Authentication answers: <strong>are you who you claim to be?</strong></p>
<h3 id="the-three-factor-types">The three factor types</h3>
<p>Authentication has not fundamentally changed in decades. What has changed is how cloud platforms implement it.</p>
<table>
<thead>
<tr>
<th>Factor</th>
<th>Type</th>
<th>Cloud Examples</th>
</tr>
</thead>
<tbody>
<tr>
<td>Something you know</td>
<td>Knowledge</td>
<td>Password, access key secret, PIN</td>
</tr>
<tr>
<td>Something you have</td>
<td>Possession</td>
<td>TOTP app, FIDO2 hardware key, smart card</td>
</tr>
<tr>
<td>Something you are</td>
<td>Inherence</td>
<td>Biometrics — less common in cloud contexts</td>
</tr>
</tbody>
</table>
<p>MFA requires two <strong>distinct</strong> factors. A password plus a username is not MFA — both are knowledge factors. A password plus a TOTP code is MFA. Worth stating clearly because I&#8217;ve seen internal documentation describe &#8220;username and password&#8221; as two-factor authentication.</p>
<p>SMS codes count as MFA, but they&#8217;re the weakest form. SIM-swapping attacks — convincing a carrier to port your number — have been used to defeat SMS MFA on high-value accounts. If TOTP or FIDO2 hardware keys are available, use them.</p>
<h3 id="how-aws-authenticates">How AWS authenticates</h3>
<p>AWS has two fundamentally different identity classes:</p>
<p><strong>Human identities</strong> authenticate via console (password + optional MFA) or CLI/API (Access Key ID + Secret Access Key). The access key is a long-lived credential with no default expiry. Every <code class="" data-line="">.env</code> file with an access key, every git commit that included one, every CI/CD log that printed one — that credential is live until someone explicitly rotates or deletes it.</p>
<p><strong>Machine identities</strong> — EC2, Lambda, ECS tasks — authenticate via temporary credentials issued by STS:</p>
<pre><code class="" data-line=""># Assume a role — get temporary credentials that expire
aws sts assume-role \
  --role-arn arn:aws:iam::123456789012:role/DevRole \
  --role-session-name alice-session \
  --duration-seconds 3600
# Returns: AccessKeyId + SecretAccessKey + SessionToken
# All three expire together. Nothing to rotate.

# From inside an EC2 instance — credentials arrive automatically via IMDS
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/MyAppRole
# Returns: AccessKeyId, SecretAccessKey, Token, Expiration
# AWS refreshes these before expiry. The application never sees a rotation event.
</code></pre>
<p>The IMDS model is the right one. The application never manages a credential — it appears, it&#8217;s used, it expires. If it leaks, it&#8217;s usable for hours at most, not years.</p>
<h3 id="why-long-lived-credentials-keep-appearing">Why Long-Lived Credentials Keep Appearing</h3>
<h3 id="how-gcp-authenticates">How GCP authenticates</h3>
<p>GCP cleanly separates human and machine authentication.</p>
<p>Humans authenticate via Google Account or Workspace (OAuth2). The <code class="" data-line="">gcloud</code> CLI handles the flow:</p>
<pre><code class="" data-line="">gcloud auth login                        # browser-based OAuth2 for humans
gcloud auth application-default login    # sets up Application Default Credentials for local dev
</code></pre>
<p>Machine identities use service accounts, ideally attached to the resource rather than using downloaded key files. Key files are GCP&#8217;s equivalent of long-lived AWS access keys — same problems, same risks.</p>
<pre><code class="" data-line=""># From inside a GCE VM — ADC uses the attached service account, no key file needed
gcloud auth print-access-token
# Use it: curl -H &quot;Authorization: Bearer $(gcloud auth print-access-token)&quot; ...
</code></pre>
<h3 id="how-azure-authenticates">How Azure authenticates</h3>
<p>Azure&#8217;s identity plane is Entra ID (formerly Azure Active Directory). Humans authenticate via Entra ID using OAuth2/OIDC. Machine identities use <strong>Managed Identities</strong> — Azure handles the entire credential lifecycle, nothing to configure or rotate.</p>
<pre><code class="" data-line="">az login                                  # browser-based OAuth2
az login --service-principal \            # service principal for automation
  -u APP_ID -p CERT_OR_SECRET \
  --tenant TENANT_ID

# From inside an Azure VM — get a token via IMDS, no credentials needed
curl &#039;http://169.254.169.254/metadata/identity/oauth2/token\
?api-version=2018-02-01&amp;resource=https://management.azure.com/&#039; \
  -H &#039;Metadata: true&#039;
</code></pre>
<h3 id="the-credential-failure-modes-that-repeat-everywhere">The credential failure modes that repeat everywhere</h3>
<p>In practice, the same patterns appear across all three clouds in every audit:</p>
<p><strong>Leaked credentials</strong> — access keys in git commits, <code class="" data-line="">.env</code> files, Docker image layers, CI/CD logs. GitHub&#8217;s secret scanning finds thousands of these monthly on public repos alone.</p>
<p><strong>Long-lived credentials</strong> — an access key from 2019 is still valid in 2026 unless someone explicitly rotated it. I&#8217;ve audited accounts where 30% of access keys had never been rotated, some five years old.</p>
<p><strong>Shared credentials</strong> — one key used by three services. When you revoke it, three things break. When it leaks, you can&#8217;t tell which service was the source.</p>
<p><strong>Credential sprawl</strong> — service account keys downloaded for &#8220;one quick test&#8221; and never deleted. I once found seventeen key files for a single GCP service account, created by different engineers over two years. None rotated. Five belonged to accounts that no longer existed.</p>
<p>The direction of travel in all three clouds is credential-less: workload identity federation, managed identities, instance profiles. We&#8217;ll cover this specifically in <a href="/workload-identity-oidc-service-accounts/">OIDC Workload Identity: Eliminate Cloud Access Keys Entirely</a>.</p>
<hr />
<h2 id="how-authorization-evaluates-every-api-call">How Authorization Evaluates Every API Call</h2>
<p>Authorization happens after authentication. The system knows <em>who</em> you are — now it decides <em>what</em> you can do. This decision is enforced through <a href="/iam-roles-policies-permissions-explained/">IAM roles vs policies</a> — the building blocks that express what each identity is allowed to do on which resources.</p>
<h3 id="what-the-evaluation-looks-like">What the evaluation looks like</h3>
<p>Every API call triggers an authorization check. You don&#8217;t notice when it succeeds. You notice when it fails:</p>
<pre><code class="" data-line="">REQUEST:
  Action:    s3:DeleteObject
  Resource:  arn:aws:s3:::prod-backups/2024-01-15.tar.gz
  Principal: arn:aws:iam::123456789012:role/DevEngineerRole
  Context:   { source_ip: &quot;10.0.1.5&quot;, mfa: false, time: &quot;14:32 UTC&quot; }

EVALUATION:
  1. Explicit Deny anywhere? → none found
  2. Explicit Allow in any policy? → not granted
  3. Default → DENY

RESULT: AccessDenied
</code></pre>
<p>The engineer authenticated successfully. Valid credentials, valid session. But <code class="" data-line="">DevEngineerRole</code> has no policy granting <code class="" data-line="">s3:DeleteObject</code> on that bucket. Gate 1 passed. Gate 2 denied. They are evaluated independently.</p>
<h3 id="policy-evaluation-chains-by-cloud">Policy evaluation chains by cloud</h3>
<p><strong>AWS — evaluated in layers, explicit Deny wins at any layer:</strong></p>
<pre><code class="" data-line="">1. Explicit Deny in any SCP?           → DENY (cannot be overridden anywhere)
2. No SCP Allow?                       → DENY
3. Explicit Deny in identity or resource policy? → DENY
4. Resource-based policy Allow?        → can ALLOW (same account)
5. Permissions boundary — no Allow?    → DENY
6. Session policy — no Allow?          → DENY
7. Identity-based policy Allow?        → ALLOW
Default (nothing granted):             → DENY
</code></pre>
<p>The default is always Deny. Every successful authorization is an explicit <code class="" data-line="">&quot;Effect&quot;: &quot;Allow&quot;</code> somewhere in the chain. This is the opposite of traditional Unix — in the cloud, if you didn&#8217;t explicitly grant it, it doesn&#8217;t exist.</p>
<p><strong>GCP — additive, permissions accumulate up the hierarchy:</strong></p>
<pre><code class="" data-line="">Permission granted if ANY binding grants it at:
  resource level → project level → folder level → organization level

IAM Deny Policies can override all grants (newer feature).
No binding at any level? → Denied.
</code></pre>
<p><strong>Azure RBAC:</strong></p>
<pre><code class="" data-line="">1. Explicit Deny Assignment?           → DENY (even Owner can&#039;t override)
2. Role Assignment with Allow?         → ALLOW
Default:                               → DENY
</code></pre>
<hr />
<h2 id="why-confusing-authentication-and-authorization-breaks-security">Why Confusing Authentication and Authorization Breaks Security</h2>
<h3 id="the-token-as-authorization-antipattern">The token-as-authorization antipattern</h3>
<p>An application checks for a valid JWT and if found, proceeds. The JWT proves the user authenticated with the IdP. However, it says nothing about what they&#8217;re allowed to do.</p>
<pre><code class="" data-line=""># This is authentication only — anyone with a valid token gets through
@app.route(&quot;/admin/delete-user&quot;, methods=[&quot;POST&quot;])
def delete_user():
    token = request.headers.get(&quot;Authorization&quot;)
    if verify_token(token):           # asks: is this token real and unexpired?
        delete_user_from_db(...)      # executes for any valid token holder
        return &quot;OK&quot;
    return &quot;Unauthorized&quot;, 401

# This separates the two correctly
@app.route(&quot;/admin/delete-user&quot;, methods=[&quot;POST&quot;])
def delete_user():
    token = request.headers.get(&quot;Authorization&quot;)
    principal = verify_token(token)                    # Gate 1: authentication
    if not has_permission(principal, &quot;users:delete&quot;):  # Gate 2: authorization
        return &quot;Forbidden&quot;, 403
    delete_user_from_db(...)
    return &quot;OK&quot;
</code></pre>
<h3 id="the-short-expiry-principle">The short-expiry principle</h3>
<table>
<thead>
<tr>
<th>Credential type</th>
<th>Provider</th>
<th>Typical lifetime</th>
<th>Risk</th>
</tr>
</thead>
<tbody>
<tr>
<td>Access Key + Secret</td>
<td>AWS</td>
<td>Permanent (until deleted)</td>
<td>Years of exposure if leaked</td>
</tr>
<tr>
<td>STS Temporary Token</td>
<td>AWS</td>
<td>15 min – 12 hours</td>
<td>Hours at most</td>
</tr>
<tr>
<td>OAuth2 Access Token</td>
<td>GCP / Azure</td>
<td>~1 hour</td>
<td>Short window</td>
</tr>
<tr>
<td>IMDS Token (VM)</td>
<td>All three</td>
<td>Minutes</td>
<td>Auto-refreshed by platform</td>
</tr>
</tbody>
</table>
<p>A credential that expires in an hour has a one-hour exposure window if stolen. A credential that never expires has an unlimited window. This is the operational argument for managed identities and instance profiles, beyond just convenience.</p>
<pre><code class="" data-line=""># AWS — configure max session duration at role level
aws iam update-role \
  --role-name MyRole \
  --max-session-duration 3600   # 1 hour max

# GCP — access tokens expire in ~1 hour automatically
gcloud auth print-access-token
# Refresh: gcloud auth application-default print-access-token

# Azure — token lifetime configurable in Entra ID token policies
az account get-access-token --resource https://management.azure.com/
</code></pre>
<hr />
<h2 id="production-gotchas"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Production Gotchas</h2>
<pre><code class="" data-line="">╔══════════════════════════════════════════════════════════════════════╗
║  &#x26a0;  GOTCHA 1 — &quot;We have MFA, so permissions can be broad&quot;          ║
║                                                                      ║
║  MFA protects Gate 1 only. If a session is hijacked after login    ║
║  (via malware, SSRF, or a stolen session cookie), the attacker has  ║
║  a valid, MFA-authenticated token. Gate 1 is already cleared.       ║
║  Broad permissions in Gate 2 are the full attack surface.           ║
║                                                                      ║
║  Fix: treat Gate 2 (IAM policy) as your primary blast-radius        ║
║  control. MFA buys time. Least privilege limits damage.             ║
╚══════════════════════════════════════════════════════════════════════╝

╔══════════════════════════════════════════════════════════════════════╗
║  &#x26a0;  GOTCHA 2 — Debugging AccessDenied by rotating credentials      ║
║                                                                      ║
║  AWS AccessDenied is an authorization failure. The identity         ║
║  authenticated successfully — there&#039;s no Allow in the policy.       ║
║  Rotating the access key does nothing.                              ║
║                                                                      ║
║  Fix: check the policy chain. Use simulate-principal-policy to      ║
║  confirm where the Allow is missing before touching credentials.    ║
╚══════════════════════════════════════════════════════════════════════╝

╔══════════════════════════════════════════════════════════════════════╗
║  &#x26a0;  GOTCHA 3 — Application-layer authZ with broad cloud IAM        ║
║                                                                      ║
║  &quot;The app controls access&quot; is not a substitute for scoped cloud     ║
║  IAM. An SSRF vulnerability, exposed debug endpoint, or            ║
║  compromised dependency bypasses the application layer entirely.    ║
║  The cloud identity&#039;s permissions become the attacker&#039;s surface.    ║
║                                                                      ║
║  Fix: both layers enforce least privilege independently.            ║
╚══════════════════════════════════════════════════════════════════════╝
</code></pre>
<hr />
<h2 id="authentication-vs-authorization-audit-checklist">Authentication vs Authorization Audit Checklist</h2>
<p>Split your IAM review along the authN/authZ boundary — they&#8217;re different problems with different fixes.</p>
<p><strong>Authentication — Gate 1:</strong><br />
&#8211; Are there long-lived access keys that could be replaced with STS/Managed Identity?<br />
&#8211; Is MFA enforced for all human identities with console or API access?<br />
&#8211; Are service account key files present where workload identity is available?<br />
&#8211; Are credentials stored in a secrets manager — not in code, <code class="" data-line="">.env</code> files, or repos?<br />
&#8211; When did each long-lived credential last rotate?</p>
<p><strong>Authorization — Gate 2:</strong><br />
&#8211; Does every policy follow least privilege — only the permissions the workload actually uses?<br />
&#8211; Are there wildcards (<code class="" data-line="">s3:*</code>, <code class="" data-line="">&quot;Resource&quot;: &quot;*&quot;</code>) that could be narrowed?<br />
&#8211; Are write, delete, and IAM-modification actions scoped to specific resources?<br />
&#8211; Are SCPs or permissions boundaries capping maximum permissions at org or account level?<br />
&#8211; When were each role&#8217;s permissions last reviewed against actual usage (Access Analyzer)?</p>
<hr />
<h2 id="quick-reference">Quick Reference</h2>
<pre><code class="" data-line="">┌────────────────────────────┬──────────────────────────────────────────────────┐
│ Term                       │ What it means                                    │
├────────────────────────────┼──────────────────────────────────────────────────┤
│ Authentication (AuthN)     │ Verifying identity — are you who you claim?      │
│ Authorization (AuthZ)      │ Verifying permission — are you allowed to act?   │
│ MFA                        │ Two distinct factors; strengthens Gate 1 only    │
│ STS (AWS)                  │ Security Token Service — issues temp credentials │
│ Access Key                 │ Long-lived AWS credential; avoid for services    │
│ Instance profile (AWS)     │ Container attaching a role to EC2                │
│ Managed Identity (Azure)   │ Credential-less identity for Azure services      │
│ Service Account (GCP)      │ Machine identity; prefer attached over key file  │
│ HTTP 401                   │ Authentication failure — prove who you are       │
│ HTTP 403 / AccessDenied    │ Authorization failure — fix the policy           │
└────────────────────────────┴──────────────────────────────────────────────────┘

Commands to know:
┌──────────────────────────────────────────────────────────────────────────────┐
│  # AWS — assume a role and get temporary credentials                        │
│  aws sts assume-role --role-arn arn:aws:iam::ACCOUNT:role/ROLE \            │
│    --role-session-name my-session --duration-seconds 3600                   │
│                                                                              │
│  # AWS — simulate a policy to debug AccessDenied before touching anything   │
│  aws iam simulate-principal-policy \                                         │
│    --policy-source-arn arn:aws:iam::ACCOUNT:role/MyRole \                   │
│    --action-names s3:GetObject \                                             │
│    --resource-arns arn:aws:s3:::my-bucket/*                                 │
│                                                                              │
│  # AWS — check what credentials your session is using                       │
│  aws sts get-caller-identity                                                 │
│                                                                              │
│  # GCP — print the current access token (expires in ~1 hour)                │
│  gcloud auth print-access-token                                              │
│                                                                              │
│  # GCP — show which account ADC is using                                    │
│  gcloud auth application-default print-access-token                         │
│                                                                              │
│  # Azure — get current token for ARM                                         │
│  az account get-access-token --resource https://management.azure.com/       │
│                                                                              │
│  # Azure — check who you&#039;re logged in as                                     │
│  az account show                                                             │
└──────────────────────────────────────────────────────────────────────────────┘
</code></pre>
<hr />
<h2 id="framework-alignment">Framework Alignment</h2>
<table>
<thead>
<tr>
<th>Framework</th>
<th>Reference</th>
<th>What It Covers Here</th>
</tr>
</thead>
<tbody>
<tr>
<td>CISSP</td>
<td>Domain 5 — Identity and Access Management</td>
<td>AuthN and AuthZ are the two core mechanisms; this episode defines the boundary</td>
</tr>
<tr>
<td>CISSP</td>
<td>Domain 1 — Security &amp; Risk Management</td>
<td>Conflating the two creates systematic, measurable risk with different attack surfaces</td>
</tr>
<tr>
<td>ISO 27001:2022</td>
<td>5.17 Authentication information</td>
<td>Managing credentials and authentication mechanisms across the identity lifecycle</td>
</tr>
<tr>
<td>ISO 27001:2022</td>
<td>8.5 Secure authentication</td>
<td>Technical controls — MFA, session management, credential policies</td>
</tr>
<tr>
<td>ISO 27001:2022</td>
<td>5.15 Access control</td>
<td>Policy requirements that depend on cleanly separating identity from permission</td>
</tr>
<tr>
<td>SOC 2</td>
<td>CC6.1</td>
<td>Logical access controls — this episode defines the two-gate model CC6.1 is built on</td>
</tr>
<tr>
<td>SOC 2</td>
<td>CC6.7</td>
<td>Access restrictions enforced at the authorization layer, not just authentication</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li>Authentication proves identity; authorization proves permission — two gates, two separate failure modes, two separate fixes</li>
<li>AWS <code class="" data-line="">AccessDenied</code> is a Gate 2 failure — the credential is valid, the policy is missing; fix the policy</li>
<li>Short-lived credentials (STS, Managed Identities, instance profiles) reduce the blast radius of a credential compromise from years to hours</li>
<li>MFA hardens Gate 1 — it has no effect on what an authenticated identity can do</li>
<li>HTTP 401 = Gate 1 failed; HTTP 403 = Gate 2 failed — the status code tells you where to look</li>
<li>Application-layer authorization and cloud IAM authorization are independent — both must enforce least privilege</li>
</ul>
<hr />
<h2 id="whats-next">What&#8217;s Next</h2>
<p>You now know what the two gates are and where failures in each originate. <a href="/iam-roles-policies-permissions-explained/">IAM Roles vs Policies: How Cloud Authorization Actually Works</a> goes into the mechanics of Gate 2 — the permissions, policies, and roles that implement authorization in practice, and the structural patterns that keep them from turning into an unmanageable sprawl.</p>
<p><em>Next: <a href="/iam-roles-policies-permissions-explained/">IAM Roles vs Policies: How Cloud Authorization Actually Works</a></em></p>
<p>Get the IAM roles vs policies breakdown in your inbox when it publishes → <a href="https://linuxcent.com/subscribe">linuxcent.com/subscribe</a></p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fauthentication-vs-authorization-iam%2F&amp;linkname=Authentication%20vs%20Authorization%3A%20AWS%20AccessDenied%20Explained" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fauthentication-vs-authorization-iam%2F&amp;linkname=Authentication%20vs%20Authorization%3A%20AWS%20AccessDenied%20Explained" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fauthentication-vs-authorization-iam%2F&amp;linkname=Authentication%20vs%20Authorization%3A%20AWS%20AccessDenied%20Explained" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fauthentication-vs-authorization-iam%2F&amp;linkname=Authentication%20vs%20Authorization%3A%20AWS%20AccessDenied%20Explained" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fauthentication-vs-authorization-iam%2F&amp;linkname=Authentication%20vs%20Authorization%3A%20AWS%20AccessDenied%20Explained" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fauthentication-vs-authorization-iam%2F&amp;linkname=Authentication%20vs%20Authorization%3A%20AWS%20AccessDenied%20Explained" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fauthentication-vs-authorization-iam%2F&amp;linkname=Authentication%20vs%20Authorization%3A%20AWS%20AccessDenied%20Explained" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fauthentication-vs-authorization-iam%2F&#038;title=Authentication%20vs%20Authorization%3A%20AWS%20AccessDenied%20Explained" data-a2a-url="https://linuxcent.com/authentication-vs-authorization-iam/" data-a2a-title="Authentication vs Authorization: AWS AccessDenied Explained"></a></p><p>The post <a href="https://linuxcent.com/authentication-vs-authorization-iam/">Authentication vs Authorization: AWS AccessDenied Explained</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/authentication-vs-authorization-iam/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1456</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: linuxcent.com @ 2026-08-31 20:13:09 by W3 Total Cache
-->