🚗🏍️ Welcome to Motoshare!

Turning Idle Vehicles into Shared Rides & New Earnings.
Why let your bike or car sit idle when it can earn for you and move someone else forward?

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Partners earn. Renters ride. Everyone wins.

Start Your Journey with Motoshare

KEYCLOAK 26.3.3 – COMPLETE GUIDE TO BOOTSTRAP ADMIN (WORKING)

Uncategorized

Below is a fully comprehensive, step-by-step, production-ready guide for Keycloak 26.3.3 explaining:

✔ How bootstrap admin works
✔ Why admin-user.json does not exist
✔ How to create a temporary admin
✔ How to convert temporary admin → persistent admin
✔ How to start in dev/prod mode
✔ All correct commands
✔ All common errors + solutions
✔ Directory structure + security notes

This is the most detailed guide you will find for Keycloak 26.x (Quarkus).


✅ 🔥 KEYCLOAK 26.3.3 – COMPLETE GUIDE TO BOOTSTRAP ADMIN (WORKING)

Keycloak 26 uses a new security model for admin creation.

⭐ Key Changes in Keycloak 26

  1. No admin-user.json file
    ✔ Keycloak 25+ does not store admin user in data/admin-user.json anymore
    ✔ It temporarily injects admin user into DB during bootstrap, then removes it
  2. bootstrap-admin user syntax replaced create
  3. --password removed
    ✔ Only --password:env VARIABLE is allowed
  4. Admin account created is Temporary
    ✔ Exists only while server is starting
    ✔ After server exits, admin is gone unless “persisted”

🔥 PART 1 — UNDERSTANDING BOOTSTRAP ADMIN IN KEYCLOAK 26

Keycloak has two kinds of admin:

1️⃣ Temporary Admin (Bootstrap Admin)

  • Created using: kc.sh bootstrap-admin user ...
  • Lives only until Keycloak fully boots
  • After server stops → admin disappears
  • Used only to get first-time access to admin console

2️⃣ Persistent Admin (Stored in DB)

  • Created from Keycloak Admin Console
  • Stored permanently
  • Does NOT depend on bootstrap admin

❗ Keycloak does NOT store bootstrap admin in:

  • MariaDB/MySQL tables
  • admin-user.json
  • Environment variables

Therefore, you cannot see it in DB.


🔥 PART 2 — CREATING TEMPORARY ADMIN (WORKING)

Step 1 — Stop Keycloak

./bin/kc.sh stop

(If already stopped, ignore errors)


Step 2 — Set password via environment variable

export KEYCLOAK_ADMIN_PASSWORD="Admin@123"

✔ REQUIRED for Keycloak 26+
✔ Inline passwords are NOT allowed


Step 3 — Create temporary admin user

./bin/kc.sh bootstrap-admin user --username admin --password:env KEYCLOAK_ADMIN_PASSWORD

Expected output:

KC-SERVICES0077: Created temporary admin user with username admin
Keycloak started...
Keycloak stopped

✔ This confirms temporary admin is created
✔ Keycloak immediately stops after creation (normal behavior)


🔥 PART 3 — START KEYCLOAK

Development Mode (for testing)

./bin/kc.sh start-dev

URL:

http://your-domain:8080

✔ Works immediately
✔ Accepts local-only settings
✔ Auto-generates certificates
❌ Not for production


Production Mode (recommended)

./bin/kc.sh start

If you have SSL reverse proxy:

  • Apache
  • Nginx
  • HAProxy

URL:

https://auth.motoshare.in

🔥 PART 4 — LOGIN USING TEMPORARY ADMIN

Login page:

http://auth.motoshare.in:8080/admin

Use:

  • Username: admin
  • Password: Admin@123

After you log in, you MUST IMMEDIATELY create a permanent admin user.


🔥 PART 5 — CREATE PERMANENT ADMIN (VERY IMPORTANT)

Inside Admin Console:

Go to:

Master Realm → Users → Add User

Fill:

  • Username: admin
  • Email: your email
  • Enabled: ON
  • Email Verified: ON

Save → Credentials tab → Set password

  • Set: Admin@123
  • Temporary: OFF

Correct.

Now this admin is stored in your MariaDB.


🔥 PART 6 — CONFIRM ADMIN IS PERSISTENT IN DB

In MariaDB:

use keycloak;

SELECT USERNAME FROM USER_ENTITY WHERE USERNAME = 'admin';

You should see:

+----------+
| USERNAME |
+----------+
| admin    |
+----------+

✔ Now Keycloak will keep this user forever
✔ No need to use bootstrap-admin again
✔ Safe for production


🔥 PART 7 — WHY admin-user.json DOES NOT EXIST ANYMORE?

Keycloak 24+ removed this file for security reasons.

Temporary admin is not stored in filesystem.

Boot sequence:

  1. Start Keycloak
  2. Inject temporary admin into memory
  3. Start admin console
  4. Temporary admin is removed after server stops

So this is correct:

cat data/admin-user.json
No such file or directory

🔥 PART 8 — COMMON ERRORS + FIXES

❌ Error:

Unknown option: --password

✔ Fix:

Use environment variable:

export KEYCLOAK_ADMIN_PASSWORD="Admin@123"
--password:env KEYCLOAK_ADMIN_PASSWORD

❌ Error:

Missing required subcommand

✔ Fix:

Keycloak 26 requires:

bootstrap-admin user ...

Not:

bootstrap-admin create ...

❌ Admin not saved in DB

✔ You forgot to create Permanent Admin
✔ You used bootstrap-admin only
✔ bootstrap admin is temporary


❌ Cannot login after restart

Because temporary admin is gone.

✔ Create permanent admin.


🔥 PART 9 — FULL COPY–PASTE SCRIPT (PRODUCTION READY)

cd /opt/auth.motoshare.in

./bin/kc.sh stop

export KEYCLOAK_ADMIN_PASSWORD="Admin@123"

./bin/kc.sh bootstrap-admin user --username admin --password:env KEYCLOAK_ADMIN_PASSWORD

./bin/kc.sh start   # or start-dev

Then login → create permanent admin.


🔥 PART 10 — HOW TO PERSIST ADMIN BEFORE FIRST LOGIN (OPTIONAL)

If you want automatic DB admin creation without UI:

INSERT INTO USER_ENTITY (ID, EMAIL, EMAIL_CONSTRAINT, ENABLED, USERNAME, CREATED_TIMESTAMP, REALM_ID, FEDERATION_LINK, SERVICE_ACCOUNT_CLIENT_LINK) 
VALUES ('admin-id-123', 'admin@admin.com', 'admin@admin.com', 1, 'admin', 1735730400000, 'master', NULL, NULL);

INSERT INTO CREDENTIAL (ID, TYPE, USER_ID, REALM_ID, CREATED_DATE, SECRET_DATA, CREDENTIAL_DATA, PRIORITY)
VALUES (
  'cred-id-123', 
  'password', 
  'admin-id-123', 
  'master',
  1735730400000,
  '{"value":"HASHED_PASSWORD"}',
  '{"hashIterations":27500}',
  0
);

(Note: You must generate password hash via Keycloak API → I can provide)


🎯 FINAL SUMMARY

TaskCommand
Create temporary adminbootstrap-admin user --username admin --password:env KEYCLOAK_ADMIN_PASSWORD
Set password envexport KEYCLOAK_ADMIN_PASSWORD="Admin@123"
Start dev modekc.sh start-dev
Start prodkc.sh start
Permanent adminCreate via admin console
Check admin in DBSELECT USERNAME FROM USER_ENTITY

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x