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 and works only when an external database (like PostgreSQL) is used.
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:
uds zarf tools kubectl exec -it keycloak-0 -n keycloak -- /opt/keycloak/bin/kc.sh bootstrap-admin user --verbose --optimized --http-management-port=9001When prompted, enter the temp-admin password:
Enter username [temp-admin]: <enter>Enter password: <temp-admin password>Enter password again: <temp-admin password>The command will exit with no errors. Ensure this line is present in the output:
<timestamp> INFO [org.keycloak.services] (main) KC-SERVICES0077: Created temporary admin user with username temp-adminNavigate 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.