SyntaxHighlighter JS


Change the username and password of Apache Karaf admin user

What you will do:
  • Change the username and password for Apache Karaf admin user
What you will learn:
  • Overwrite default Karaf configuration files
  • Use Maven filtered resources
Please see the post "Create a custom Apache Karaf server" for the initial setup.

By default, the admin user has the username/password of karaf/karaf.  For branding purposes, we want to rename the username/password of dekantar/dekantar .

Step 1: Define username/password
Define the username/password as Maven properties in the pom.xml


Step 2: Turn on Maven filtered resources
Filtered resource will substitute Maven variables in text files with the property values

The filtering is true property turns on variable substitution in the src/main/filtered-resources directory.

Step 3: Overwrite default Karaf security file
The default Karaf security file is etc/ To overwrite, create the file src/main/filtered-resources/etc/

The content of etc/ is

${dekantar.username} = ${dekantar.password},_g_:admingroup
_g_\:admingroup = group,admin,manager,viewer,webconsole

The variable substitution results in the output

dekantar = dekantar,_g_:admingroup
_g_\:admingroup = group,admin,manager,viewer,webconsole

Don't worry about the clear text password. Karaf will automatically encrypt it on first login.

Step 4: Test it
After building the Karaf server, start it via command

cd $KARAF_DIR/bin

Then log in with the new username

ssh dekantar@localhost -p8101

No comments:

Post a Comment