Keycloak V18 - Unable to get first admin user trough environement variables

Hi everyone,
I am installing the fresh new Quarkus Keycloak V18 on a Centos 7.
Since i don’t have Gui i am unable to connect on localhost to set up the first admin user.
I have tried to set the environment variables like it says on the documentation :Configuring Keycloak - Keycloak
On my Gnu/Linux, printenv does show the Env Vars : KEYCLOAK_ADMIN and KEYCLOAK_ADMIN_PASSWORD
But i am not able to see why it’s not working. i’ve stoped the server / Build it again and start it. I am still having on the web interfacing the message inviting me to log on localhost to create the first admin user.
Thank you for your help.


the environment variables have changed considerably in the Keycloak.X distribution.
You can now use the following env variables to create an admin user:

# Keycloak.X

How are you running the keycloak server? It’s possible those env variables are set in your environment when running a login shell to run printenv but not set in the environment for your keycloak server, e.g. if you set the variables in ~/.bashrc but run keycloak as a different user.

1 Like

Ho Thomas,

thanks for your reply. I am trying to use this variables, but Keycloack seems not using this Env variables.

Thanks for your reply.
Good guess, i’ve created a user with no home / no ssh so it can only run the application and own it :

sudo useradd -r -g keycloak -d /opt/keycloak -s /sbin/nologin keycloak

i am creation the ENV VARs using my super admin user :

# export KEYCLOAK_ADMIN=kclk_admin

And when i try to printenv with the keycloak user, it cannot see my created variables.
I guess i need to give my user a home so i can create hes own bashrc.
I will give a feedback trying this. If by any chance you have a best solution, feel free to reply :slight_smile:

@Ergo0ne you could define a systemd service to run keycloak, that would allow you to define the environment values as well as providing other benefits e.g. auto-restarting. Here is a tutorial for setting it up using systemd Keycloak 17 & FileMaker: Installation & Configuration Tutorial Part 4: Starting Keycloak 17 & Next Steps - Sounds Essential LLC

1 Like

Creating a new user with home and a .bashrc resolved for me the issue.
Thanks :slight_smile: