Saturday 16 September 2023

KeyCloak Installation and Basic Configuration::

 Installation::

========================

Download keycloak from keycloak.org/downloads

 wget https://github.com/keycloak/keycloak/releases/download/22.0.3/keycloak-22.0.3.tar.gz

 tar -zxvf keycloak-22.0.3.tar.gz


Create Self-signed certificate for Keycloak

openssl req -newkey rsa:2048 -nodes -keyout keycloak-server.key.pem -x509 -days 3650 -out keycloak-server.crt.pem

Copy the key and cert to /usr/share/ssl-cert/

cd keycloak-22.0.3

cd conf

Edit keycloak.conf to  update hostname, certificate and key location in Prod Environment. As this is a test environment, I am using a self-signed certificate and the server local ipaddress.

https-certificate-file=/usr/share/ssl-cert/keycloak-server.crt.pem

https-certificate-key-file=/usr/share/ssl-cert/keycloak-server.key.pem

hostname=172.16.22.136


Goto Keycloak/bin and run the build and start up commands below

./kc.sh build

nohup ./kc.sh start &


Configuration::

==============================

For Keycloak server configuration follow the server administration doc in the Url:- https://www.keycloak.org/docs/latest/server_admin/

Initially login to the Keycloak as admin user. You can create the admin user and password  from the console or set environment variables 

KEYCLOAK_ADMIN=admin
KEYCLOAK_ADMIN_PASSWORD=password

Create New Realm under the Create Realm Menu. A realm manages a set of users, credentials, roles and groups. Master realm is provided as a default realm in Keycloak. Creating multiple realms can enable multiple tenency.


To enable user registration, Goto  under Realm Settings--> Login--> Enable User Registration




To enable Client Authentication, Goto  Clients--> Enable Client Authentication



To Apply new themes, copy the custom theme jar file under the providers folder and run 

"/bin/kc.sh config" command to configure and install the custom providers.


User Management in Keycloak::-

* Self Registration
* From Admin Console
* User Federation
* Automation via API's





Makefile

 If we are compiling a lot of source code files and something goes wrong half way through, it might be nice to be able to pick where we left off in order to finish compiling after we fix the error. Below is an example of a simple Makefile


make command will follow the Makefile and  some of the make command directives are below:-


make clean
make install           
make all
make uninstall

====================

root@debian:~# cat Makefile

all: program

program: main.o  factorial.o

     g++ main.o  factorial.o -o program

main.o: main.cpp

     g++ -c main.cpp

factorial.o: factorial.cpp

     g++ -c factorial.cpp

clean:

     rm -rf *.o program

=====================


=====================

root@debian:~# cat factorial.cpp

#include "functions.h"

int factorial(int n){

   if(n!=1){

      return(n * factorial(n-1));

   } else return 1;

}

======================


======================

root@debian:~# cat functions.h

int factorial(int n);

======================


======================

root@debian:~# cat main.cpp

#include <iostream>

using namespace std;

#include "functions.h"

int main(){

   cout << endl;

   cout << "The factorial of 5 is " << factorial(5) << endl;

   return 0;

}

=======================

Thursday 14 September 2023

Kernel Compilation in Debian from 6.1.0 to 6.5.3

 Kernel Compilation in Debian from 6.1.0 to 6.5.3



uname -r

6.1.0


Download the linux kernel version

wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.5.3.tar.xz


Untar it

tar -xf linux-6.5.3.tar.xz


Install the necessary dependencies


apt-get install build-essential linux-source bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves bison


Reboot the server


Run the below commands


make mrproper

This removes any configuration files that might have been accidentally left over from previous builds.


Copy the old .config file


make olddefconfig


Run the below command to make the configuration changes in .config file. 

make menuconfig



Running make localmodconfig will take your current .config and turn off any unused modules.

make localmodconfig


Build the  New Kernel

make -j$(nproc)


Install the kernel modules and the kernel itself:

make modules_install

make install


Reboot the server

shutdown -r now


Run the uname command to know the kernel version

uname -r

6.5.3