Posts

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]...

How to resolve port conflict in websphere

 To resolve port conflicts in WebSphere Application Server on Linux, you can follow the below steps: Determine the port that is in conflict: a. Login in server b. Run the command: ./netstat -an | grep <port> where <port> is the port number that is in conflict. Identify the process that is using the port: a. Run the command: ps -ef | grep <PID> where <PID> is the Process ID (PID) of the process that is using the port. Stop the process that is using the port: a. Use the kill command to stop the process: kill -9 <PID> where <PID> is the Process ID of the process that is using the port. b. Change port in serverindex.xml file if required  c.Stop node and sync with dmgr then start node Restart the WebSphere Application Server: a. Go to the WebSphere installation directory: cd /opt/IBM/WebSphere/AppServer/bin b. Run the command: ./stopServer.sh <server_name> where <server_name> is the name of the server that you modified the port number...

DerInputStream class is available in rt.jar and ibmpkcs.jar in Websphere

  The DerInputStream class is a part of the Java Cryptography Extension (JCE) API and is typically included in the rt.jar file of the Java runtime environment. As for Websphere, the ibmpkcs.jar file is an IBM-provided package that contains classes for PKCS-related functionality, including the DerInputStream class. So it is possible that the DerInputStream class is available in both rt.jar and ibmpkcs.jar in Websphere, depending on the specific version and configuration of Websphere being used. To import the com.ibm.security.util.DerInputStream class in your Java program, you can use the following import statement: import com.ibm.security.util.DerInputStream; Note that in order to use this class, you need to have the IBM Security Provider JAR file (ibmpkcs.jar) in your classpath. You can download this JAR file from the IBM website or obtain it from your Websphere installation directory. Once you have added the JAR file to your classpath, you should be able to import and ...

shell script to import certificate in cacerts of JDK

#!/bin/bash # Set the path to the cacerts file CACERTS_FILE="${JAVA_HOME}/jre/lib/security/cacerts" # Prompt for the path to the certificate file printf "Enter path to certificate file: " read CERT_PATH # Prompt for the alias for the certificate in the keystore printf "Enter alias for certificate: " read CERT_ALIAS # Prompt for the keystore password printf "Enter keystore password: " read -s PASSWORD echo # Import the certificate into the cacerts file keytool -importcert -alias "${CERT_ALIAS}" -file "${CERT_PATH}" -keystore "${CACERTS_FILE}" -storepass "${PASSWORD}" # Verify the certificate was imported successfully keytool -list -v -keystore "${CACERTS_FILE}" -storepass "${PASSWORD}" | grep "${CERT_ALIAS}" In this version of the script, we prompt the user to enter the path to the certificate file, the alias for the certificate in the keystore, and the keystore password using t...

shell script to scp multiple file to multiple destinations

  #!/bin/bash # Prompt the user for the name of the file to transfer using printf and read commands printf "Enter the name of the file to transfer: " read filename # Prompt the user for the IP addresses to transfer the files to using printf and read commands printf "Enter the IP addresses to transfer the file(s) to (separated by spaces): " read -a ips # Define the username to use for the SCP transfer username="user" # Loop through the array of IP addresses and transfer the file to each one for ip in "${ips[@]}" do     # Use printf to display a message before transferring each file     printf "Transferring %s to %s...\n" "$filename" "$ip"         # Use scp to transfer the file to the current IP address     scp "$filename" "${username}@${ip}:~/" done # Use printf to display a summary message when the transfers are complete printf "Transferred %s to %d IP addresses.\n" "$filename"...

shell script to retrieve ssl certificate by using openssl s_client

 shell script to retrieve ssl certificate by using openssl client #!/bin/bash # Function to retrieve certificate for a given hostname and port function get_cert {   HOSTNAME="$1"   PORT="$2"   # Retrieve the certificate and extract the end-entity certificate   CERT=$(echo | openssl s_client -showcerts -servername "$HOSTNAME" -connect "$HOSTNAME":"$PORT" 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sed -n '1,/END CERTIFICATE/p')   # Save the certificate in PEM format to a file   echo "$CERT" > site_cert.pem   echo "Certificate for $HOSTNAME:$PORT saved to site_cert.pem" } # Array of sites and corresponding ports SITES=(   "example.com:443"   "google.com:443"   "yahoo.com:443"   "github.com:443"   "reddit.com:443"   "twitter.com:443"   "linkedin.com:443"   "stackoverflow.com:443" ) # Print the l...

Common 301 Redirect Htaccess Rules

Here are some common 301 redirect rules that can be added to an .htaccess file: Redirect a single page: Redirect 301 /old-page.html http://www.example.com/new-page.html This rule redirects the old page "/old-page.html" to the new page "http://www.example.com/new-page.html". Redirect an entire domain: Redirect 301 / http://www.newdomain.com/ This rule redirects all pages on the old domain to the home page of the new domain. Redirect a directory: RedirectMatch 301 ^/old-directory/(.*)$ http://www.example.com/new-directory/$1 This rule redirects all pages in the old directory "/old-directory/" to the corresponding pages in the new directory "/new-directory/". The "$1" is a backreference to the part of the URL that matches the "(.*)" pattern. Redirect all non-www requests to www: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.example\.com$ RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] This rule redirects ...