Posts

Shell script to find out aliases and import new cert in jdk

 #!/bin/bash # Function to display the available aliases in the cacerts file function display_aliases {     printf "Available aliases in $cacerts_path:\n"     keytool -list -keystore $cacerts_path -storepass changeit | grep "Alias name:" | sed 's/^.*Alias name: //' } # Function to import a certificate into the cacerts file function import_certificate {     printf "Enter the path to the certificate file: "     read cert_path     printf "Enter an alias for the certificate: "     read cert_alias     cd cacerts cacerts_bkp     keytool -import -alias $cert_alias -file $cert_path -keystore $cacerts_path -storepass changeit     printf "Certificate imported with alias $cert_alias.\n" } # Function to delete a certificate from the cacerts file function delete_certificate {     printf "Enter the alias of the certificate to delete: "     read cert_alias     keytool -delete -a...

shell script that uses the openssl command to retrieve the certificate of an external site through a proxy

  #!/bin/bash # Set the proxy server details PROXY_HOST="proxy.example.com" PROXY_PORT="8080" PROXY_USER="proxy_username" PROXY_PASS="proxy_password" # Set the URL of the site to retrieve the certificate for SITE_URL="www.example.com" # Set the path to the output file for the certificate CERT_FILE="example.com.crt" # Set the OpenSSL configuration file for the proxy PROXY_CONFIG=$(cat << EOF [proxy] http_proxy = http://$PROXY_USER:$PROXY_PASS@$PROXY_HOST:$PROXY_PORT https_proxy = https://$PROXY_USER:$PROXY_PASS@$PROXY_HOST:$PROXY_PORT EOF ) # Create a temporary OpenSSL configuration file for the proxy echo "$PROXY_CONFIG" > proxy.conf # Use the OpenSSL command to retrieve the certificate for the site through the proxy openssl s_client -connect $SITE_URL -servername $SITE_URL -proxy $PROXY_HOST:$PROXY_PORT -proxy_type http -showcerts </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' ...

Shell script to find out aliases and their expiration in cacerts

  #!/bin/bash # Set the path to the Java installation directory JAVA_HOME="/opt/java" # Set the password for the keystore KEYSTORE_PASS="keystore_password" # List all aliases in the keystore ALIASES=$(keytool -list -v -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass $KEYSTORE_PASS | grep "Alias name:" | awk '{print $3}') # Loop through the aliases and get the expiration date for each certificate for ALIAS in $ALIASES; do     # Get the expiration date in human-readable format     EXP_DATE=$(keytool -list -v -alias $ALIAS -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass $KEYSTORE_PASS | grep "Valid from" | awk '{print $3 " " $4 " " $7 " " $6}')     # Print the alias name and expiration date     echo "Alias Name: $ALIAS"     echo "Expiration Date: $EXP_DATE"     echo "" done Replace "/path/to/java" with the path to your Java installation directory, ...

Shell script to create self singed certificate for ibm http server by using gsk

  #!/bin/bash # Define variables KDB_PATH="/tmp/kdb.kdb" KDB_PASSWORD="password" CER_PATH="/tmp/cert.cer" # Prompt for certificate details printf "Enter the certificate label: "  read CERT_LABEL printf "Enter the certificate subject (e.g. /C=US/ST=California/L=San Francisco/O=Your Organization/CN=Your Domain): "  read CERT_SUBJECT printf "Enter the certificate expiration (in days): "  read CERT_EXPIRATION # Create a new kdb file ./gsk8capicmd_64 -keydb -create -db $KDB_PATH -pw $KDB_PASSWORD -stash # Generate a self-signed certificate ./gsk8capicmd_64 -cert -create -db $KDB_PATH -pw $KDB_PASSWORD -label $CERT_LABEL -dn "$CERT_SUBJECT" -size 2048 -expire $CERT_EXPIRATION # Extract the .cer file ./gsk8capicmd_64 -cert -extract -db $KDB_PATH -pw $KDB_PASSWORD -label $CERT_LABEL -target $CER_PATH

Shell script to raise csr by using openssl

 #!/bin/bash # Set variables CA_SERVER="ca.example.com" CA_PORT="443" CA_USERNAME="username" CA_PASSWORD="password" CSR_FILE="mydomain.csr" CERT_FILE="mydomain.crt" KEY_FILE="mydomain.key" # Prompt user for certificate details printf "Enter the common name (e.g. example.com): " read COMMON_NAME printf "Enter the two-letter country code (e.g. US): " read COUNTRY printf "Enter the state or province name: " read STATE printf "Enter the locality or city name: " read LOCALITY printf "Enter the organization name: " read ORGANIZATION printf "Enter the organizational unit name: " read ORG_UNIT # Generate private key openssl genrsa -out "$KEY_FILE" 2048 # Create CSR openssl req -new -key "$KEY_FILE" -out "$CSR_FILE" -subj "/C=$COUNTRY/ST=$STATE/L=$LOCALITY/O=$ORGANIZATION/OU=$ORG_UNIT/CN=$COMMON_NAME" echo "CSR generated a...

Script to search for errors in the logs of all the JVM and send mail

  the script to search for errors in the logs of all the JVMs. Here's an example of how you can modify the script: #!/bin/bash # Set the path to the logs directory LOGS_DIR="/logs/servers" # Set the email address to send notifications to EMAIL_ADDRESS="user@example.com" # Search the logs directory for SystemOut.log files and check for errors for log_file in $(find $LOGS_DIR -name "SystemOut.log"); do   # Search the log file for errors   ERRORS=$(grep -E "(ERROR|FATAL)" $log_file)   # If errors are found, send an email notification   if [ -n "$ERRORS" ]; then     echo "$ERRORS" | mail -s "Error found in WebSphere SystemOut.log for $log_file" $EMAIL_ADDRESS   fi done Save the above script to a file, for example, check_websphere_logs.sh and make it executable using the chmod command: chmod +x check_websphere_logs.sh To run the script, simply execute it from the command line: ./check_websphere_logs.sh The script will...

Linux commands that are frequently used by middleware administrators

 top: This command shows you the processes that are currently running on your system, along with their resource usage, such as CPU and memory usage. ps: This command is used to display information about the active processes on your system, including their process ID (PID), status, and resource usage. netstat: This command is used to display information about active network connections and open ports on your system. df: This command displays the amount of free and used disk space on your system's file systems. grep: This command is used to search for a specific pattern or text string in a file or output. tail: This command is used to display the last few lines of a file or output. less: This command allows you to view and scroll through the contents of a file, similar to the "more" command, but with more advanced features. find: This command is used to search for files or directories on your system based on various criteria, such as name, size, or modification date. chmod:...