You are on page 1of 13

Name: Rahul Singh Nagesh

Batch: B7 (CCVT)

Subject: Cloud Security Management Lab

SAP-ID: 500096747

Roll- R2142211428

Experiment -7
Keycloak

Experiment
a) Installing and configuring keycloak
Prerequisites
• JDK 17 and Above
Step 1) Go to keycloak website and download keycloak.

Step 2) Extract the keycloak zip file and go inside the keycloak extracted folder and type
CMD on the above address bar to open the folder in CMD.
Step 3) Generate t a key pair with specific parameters and store it in a keystore file.

keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -
dname "CN=server" -alias server -ext "SAN:c=DNS:Localhost,IP:127.0.0.1" -keystore
conf/server.keystore

Step 4) Here comes the twist , you can either go to bin folder and then run the keycloak
application or configure and attach the database and run.

The first option might run for you once but will crash after running for some time or when
you start it again, So it is recommended to configure the database

Temporary Solution to run (If you only want to run keycloak and not use it )
Go to bin folder – cd bin
kc.bat start-dev --db-pool-initial-size 100

This command limits the number of connections to the H2 database (Database written in java
used by keycloak ) but the size of the database is so small that after some time it will crash or
will not run at all .
Permanent Solution (Configure and attach a databse)

Step 5) Download and install MariaDB (I downloaded version 10.6.17).

Remember the password


Do Remember the port number you’ve given. (I Gave 3307 because MYSQL was using it already)

Step 6) Install Dbeaver (SQL Client) and open DBeaver.


Step 7) Click on File -> New -> Dbeaver -> Database connection.

Step 8) Select MariaDB here.


Step 9) Enter the port number of MariaDB you entered during installation, and the password you
gave and click on finish.

Step 10) Click on Localhost -> Create -> Database.


Step 11) Select Chartset – ut8mb4 and click on Ok.

Step 12) Click on localhost -> Users -> Create user.


Step 13) Give it Username and password and click on check all.
Step 14) After that click on schema privileges

Step 15) Click on Check All and Save.


Step 16) Now Go to you Keycloak Folder.

Open Conf Folder

Open the keycloak CONF file

It might look like this

Step 17) Edit it like this


Uncomment the parameter and enter the configuration like this

Do enter your details and port number

Additionally you can add the port number the keycloak will run on (by default in will run on 8080)

Step 18) Save the close the file and now go back to CMD , and to open the keycloack/bin folder

And run keycloak using following command

Kc.bat start-dev

Step 19) Create and admin user and password and log in.

You might also like