Change admin console password in websphere

#!/bin/sh

# Set the necessary environment variables

was_home="/opt/IBM/WebSphere/AppServer"

export PATH=$PATH:$was_home/bin

export JAVA_HOME=/usr/java8_64

# Prompt the user to enter the current and new passwords

printf "Enter the current password for admin: "

stty -echo

read old_password

stty echo

echo ""

printf "Enter the new password for admin: "

stty -echo

read new_password

stty echo

echo ""


# Connect to the running WebSphere Application Server instance

./wsadmin.sh -lang jython -f changepassword.py "$old_password" "$new_password"

exit 0

This script uses the printf command to display the prompt message to the user. The stty command is used to temporarily turn off echo mode when reading the password input.


The changepassword.py file should  contain content the same wsadmin commands as before:


import sys

# Get the old and new passwords from command line arguments

old_password = sys.argv[0]

new_password = sys.argv[1]


# Change the admin console password

AdminTask.changeFileRegistryAccountPassword('[-userId admin -password ' + old_password + ' -newPassword ' + new_password + ']')

AdminConfig.save()

AdminControl.invoke(AdminControl.getCell(),'terminate')


Comments

Popular posts from this blog

Shell script to find out aliases and their expiration in cacerts

shell script to scp multiple file to multiple destinations

How to resolve port conflict in websphere