Proxmox
One-time setup
Keycloak (realm nycmesh, client jon): create a flat group (no spaces, no nesting —
nested groups become parent/child and PVE silently skips them; allowed chars [A-Za-z0-9._-]),
then Client -> Advanced -> Token Claims -> Groups = on.
Proxmox:
ssh root@jon.mesh.nycmesh.net 'pveum realm add keycloak --type openid \
--issuer-url https://keycloak.nycmesh.net/realms/nycmesh \
--client-id jon --client-key "<secret>" \
--username-claim username --autocreate 1 \
--groups-claim groups --groups-autocreate 1'
Grant a role to a synced group:
ssh root@jon.mesh.nycmesh.net 'pveum group add pve-admin-keycloak --comment "Keycloak: pve-admin"; \
pveum acl modify / --groups pve-admin-keycloak --roles PVEAdmin'
Roles must be attached to the PVE group before the user ever logs in —
--groups-autocreate creates the group on first login but an ACL on a non-existent group
fails, so pre-create it.
Day-to-day oneliners
# who is in which synced group
ssh root@jon.mesh.nycmesh.net 'pveum group list'
# full effective permissions of a user
ssh root@jon.mesh.nycmesh.net 'pveum user permissions willard.nilges@keycloak'
# list every ACL entry
ssh root@jon.mesh.nycmesh.net 'pveum acl list'
# read/write the realm config directly
ssh root@jon.mesh.nycmesh.net 'cat /etc/pve/domains.cfg'
# add a read-only auditor group (Keycloak group must be named "pve-auditor")
ssh root@jon.mesh.nycmesh.net 'pveum group add pve-auditor-keycloak; \
pveum acl modify / --groups pve-auditor-keycloak --roles PVEAuditor'
# scoped admin (one pool only)
ssh root@jon.mesh.nycmesh.net 'pveum acl modify /pool/poolMeshDbDev --groups pve-admin-keycloak --roles PVEAdmin'
# remove an ACL
ssh root@jon.mesh.nycmesh.net 'pveum acl delete / --groups pve-admin-keycloak --roles PVEAdmin'
# custom role instead of a builtin one
ssh root@jon.mesh.nycmesh.net 'pveum role add VMOperator -privs "VM.Allocate VM.Audit VM.Console VM.PowerMgmt"'
# kick a Keycloak user out of Proxmox (group no longer synced, user stays until deleted)
ssh root@jon.mesh.nycmesh.net 'pveum user delete willard.nilges@keycloak'
Gotchas
- Group sync only happens on login (token exchange). Add someone to a Keycloak group, they must sign in to Proxmox again for the PVE membership to appear.
groups-overwrite 1is currently set on thekeycloakrealm: every login deletes all of that user's other PVE group memberships. Don't hand-manage memberships for Keycloak-realm users; turn it off withpveum realm modify keycloak --groups-overwrite 0if you want to mix sources.--propagateon the realm only matters for multi-node clusters.- The client secret is stored in cleartext in
/etc/pve/domains.cfg(replicated over the cluster via PVE's datastore). - Builtin roles:
Administrator,PVEAdmin,PVEVMAdmin,PVEAuditor,PVEDatastoreAdmin,PVESDNAdmin,PVEUserAdmin, ... (pveum role list). - Verify a mapping went through by grepping the daemon log for the sync messages:
ssh root@jon.mesh.nycmesh.net 'journalctl -u proxmox -g "openid" | tail -20'
# -> "openid user 'x@keycloak' added to groups: pve-admin-keycloak"
No comments to display
No comments to display