<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Keycloak on inetshell</title><link>https://inet.sh/en/tags/keycloak/</link><description>Recent content in Keycloak on inetshell</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 25 Sep 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://inet.sh/en/tags/keycloak/index.xml" rel="self" type="application/rss+xml"/><item><title>Proxmox VE with Keycloak: OpenID Connect login (openid realm)</title><link>https://inet.sh/en/posts/proxmox/keycloak-openid-connect/</link><pubDate>Fri, 25 Sep 2026 00:00:00 +0000</pubDate><guid>https://inet.sh/en/posts/proxmox/keycloak-openid-connect/</guid><description>Authenticate to Proxmox VE with Keycloak through an OpenID Connect realm: confidential client on Keycloak 26, pveum realm add with issuer-url, client-id, client-key and username-claim preferred_username, auto-created users, permissions and groups. No extra mappers, no /auth/ in the URL.</description><content:encoded><![CDATA[<h2 id="tldr">TL;DR</h2>
<p>In Keycloak: <strong>Clients → Create client</strong> → OpenID Connect, Client ID <code>proxmox</code>, <em>Client authentication</em> <strong>On</strong>, <em>Standard flow</em> <strong>On</strong>, <em>Valid redirect URIs</em> <code>https://pve.example.local:8006</code> and <code>https://pve.example.local:8006/*</code>. Copy the secret from the <strong>Credentials</strong> tab.</p>
<p>On a Proxmox node:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">pveum realm add keycloak --type openid <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>  --issuer-url https://id.example.local/realms/lab <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>  --client-id proxmox <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>  --client-key <span class="s1">&#39;&lt;client-secret&gt;&#39;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>  --username-claim preferred_username <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>  --autocreate <span class="m">1</span> <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>  --comment <span class="s1">&#39;Keycloak&#39;</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>Users log in as <code>alice@keycloak</code>. They are created on first login, <strong>with no permissions</strong>; permissions are still Proxmox ACLs:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">pveum group add sso-admins
</span></span><span class="line"><span class="cl">pveum acl modify / --groups sso-admins --roles Administrator
</span></span><span class="line"><span class="cl">pveum user modify alice@keycloak --groups sso-admins     <span class="c1"># after their first login</span>
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="how-it-works">How it works</h2>
<p>Proxmox has supported <code>openid</code> realms since PVE 7. From <code>issuer-url</code> it downloads <code>/.well-known/openid-configuration</code> and takes the endpoints from there; the login screen shows the realm in the dropdown and the <strong>Login</strong> button redirects to Keycloak. On the way back, the value of the claim you picked in <code>username-claim</code> becomes the user <code>&lt;claim&gt;@&lt;realm&gt;</code>.</p>
<p><code>username-claim</code> accepts any claim name. Keycloak sends <code>preferred_username</code> by default (it comes from the <em>username</em> mapper in the <code>profile</code> client scope), so the <strong>extra mapper</strong> old guides added to expose a claim called <code>username</code> <strong>is not needed</strong>. If you prefer the email, <code>--username-claim email</code>.</p>
<h2 id="keycloak-step-by-step-26">Keycloak, step by step (26)</h2>
<ol>
<li><strong>Realm.</strong> Use the one you have (<code>lab</code> in the example). The issuer is <code>https://id.example.local/realms/lab</code>. Since Keycloak 17 there is no <code>/auth/</code> in the path; if you copy <code>/auth/realms/...</code> from an old guide, discovery fails.</li>
<li><strong>Clients → Create client.</strong>
<ul>
<li><em>Client type</em>: OpenID Connect. <em>Client ID</em>: <code>proxmox</code>. <em>Name</em>: whatever you like.</li>
<li><em>Capability config</em>: <strong>Client authentication On</strong> (confidential client, with secret). <strong>Standard flow On</strong>. Everything else Off: <em>Direct access grants</em>, <em>Implicit flow</em>, <em>Service accounts</em>, <em>Authorization</em>.</li>
<li><em>Login settings</em>: <em>Root URL</em> <code>https://pve.example.local:8006</code>; <em>Valid redirect URIs</em> <code>https://pve.example.local:8006</code> and <code>https://pve.example.local:8006/*</code>. <em>Web origins</em> empty: it is a redirect flow, there is no CORS.</li>
</ul>
</li>
<li><strong>Credentials</strong> → <em>Client secret</em>. That is the <code>--client-key</code>.</li>
<li><strong>Groups (optional).</strong> Clients → <code>proxmox</code> → <em>Client scopes</em> → <code>proxmox-dedicated</code> → <em>Add mapper</em> → <em>By configuration</em> → <strong>Group Membership</strong>: <em>Name</em> <code>groups</code>, <em>Token Claim Name</em> <code>groups</code>, <em>Full group path</em> Off, <em>Add to ID token</em> and <em>Add to userinfo</em> On.</li>
</ol>
<h2 id="proxmox-step-by-step">Proxmox, step by step</h2>
<p>Through the GUI: <strong>Datacenter → Permissions → Realms → Add → OpenID Connect Server</strong>: <em>Issuer URL</em>, <em>Realm</em> (the short name, <code>keycloak</code>), <em>Client ID</em>, <em>Client Key</em>, <em>Username Claim</em> <code>preferred_username</code>, <em>Autocreate Users</em>. Or the <code>pveum realm add</code> from the TL;DR; the configuration lands in <code>/etc/pve/domains.cfg</code> and replicates across the cluster.</p>
<p>With groups coming from Keycloak, on recent PVE 8 releases and on PVE 9 (<code>pveum realm add --help</code> tells you whether your version has <code>--groups-claim</code>):</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">pveum realm modify keycloak --groups-claim groups --groups-autocreate <span class="m">1</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>Each group in the claim is created as <code>&lt;group&gt;-keycloak</code> and the user joins them on every login; you assign the ACLs to those groups.</p>
<p>Test before touching anything else: login screen → Realm <strong>Keycloak</strong> → <strong>Login</strong> → you come back authenticated and <code>pveum user list</code> shows <code>alice@keycloak</code>.</p>
<h2 id="traps">Traps</h2>
<ul>
<li><strong><code>Invalid parameter: redirect_uri</code></strong> in Keycloak: the URL you typed in the browser (name, port <code>8006</code>, <code>https</code>) is not in <em>Valid redirect URIs</em>. If you use both the IP and the FQDN, add both.</li>
<li><strong>The node must trust Keycloak&rsquo;s certificate</strong>, not just your browser. With an internal CA: copy the <code>.crt</code> to <code>/usr/local/share/ca-certificates/</code> and run <code>update-ca-certificates</code>.</li>
<li><strong><code>issuer-url</code> has to match exactly</strong> the <code>iss</code> in the tokens: <code>https</code>, no trailing slash, <code>/realms/&lt;realm&gt;</code>.</li>
<li><strong>Time.</strong> A skewed clock invalidates tokens; <code>chrony</code> on the nodes.</li>
<li><strong>Do not let users edit their own username</strong> in Keycloak (a warning from Proxmox&rsquo;s own docs): renaming yourself to <code>root</code> is switching accounts in Proxmox.</li>
<li><strong>Do not set <code>--default 1</code> until it works</strong>, and keep <code>root@pam</code> as the emergency door: if Keycloak is down, the <code>openid</code> realm cannot authenticate anyone.</li>
<li><strong>API and CLI.</strong> OIDC users have no password in Proxmox; for Terraform, Ansible, or <code>pvesh</code> from outside create a token: <code>pveum user token add alice@keycloak automation --privsep 0</code>.</li>
</ul>
<p>Reference: <a href="https://pve.proxmox.com/pve-docs/chapter-pveum.html#user-realms-oidc">User Management — OpenID Connect</a> in the Proxmox guide and <a href="https://www.keycloak.org/docs/latest/server_admin/index.html#_oidc_clients">client creation</a> in the Keycloak documentation.</p>
]]></content:encoded></item></channel></rss>