Skip to content

Recovering lost Keycloak credentials

This procedure describes how to recover lost Keycloak credentials for UDS Core. It leverages the Admin bootstrap and recovery feature of Keycloak.

The procedure involves creating a new user with administrator privileges, logging into that user, recovering the lost credentials and deleting it. First, create a new temporary admin user called temp-admin with a strong password:

Terminal window
uds zarf tools kubectl exec -it keycloak-0 -n keycloak -- /opt/keycloak/bin/kc.sh bootstrap-admin user

When prompted, enter the temp-admin password:

Terminal window
Enter username [temp-admin]: <enter>
Enter password: <temp-admin password>
Enter password again: <temp-admin password>

The command will exit with an error indicating that it can’t bootstrap the Keycloak server (this is normal as there’s already a Keycloak server running in this container). Ensure this line is present in the output:

Terminal window
<timestamp> INFO [org.keycloak.services] (main) KC-SERVICES0077: Created temporary admin user with username temp-admin

Navigate to https://keycloak.admin.uds.dev/ and log in with the temp-admin user. Once logged in, reset the admin user password by navigating to the Users tab, selecting admin, going to the Credentials tab, and clicking on Reset Password. Once the admin password has been updated, delete the temp-admin user.