Forum Discussion

ralph_ralf's avatar
ralph_ralf
Icon for Altostratus rankAltostratus
Jul 15, 2023

how to run the below bash file on f5

Hello,

I would like to extract a list of all virtual servers , profiles and certificates on my F5 ; I found the below script but I dont know how to run it on f5.Where should I place the cert-mapping file ? In which folder on f5 ?

  • Log on to the BIG-IP command line.

    Note: Command line access defaults to the bash shell.

  • Using a text editor, create the cert-mapping file.
  • Place the following bash script contents in the cert-mapping file:

    #!/bin/bash
    # Search /config and sub directories (partitions) for bigip.conf files
    LIST=`find /config -name bigip.conf |  xargs  awk '$2 == "virtual" {print $3}' 2> /dev/null | sort -u`
    echo "Virtual:          Profile:        Certificate:          Ciphers:"
    echo "__________________________________________________________"
    for VAL in ${LIST}
    do
    PROF=`tmsh show /ltm virtual ${VAL} profiles 2> /dev/null | grep -B 1 " Ltm::ClientSSL Profile:" | cut -d: -f4 | grep -i "[a-z]" | sed s'/ //'g| sort -u`
    test -n "${PROF}" 2>&- && {
    VIRTS=`expr $VIRTS + 1`
    for PCRT in ${PROF}
    do
    CERT=`tmsh list /ltm profile client-ssl ${PCRT} |  awk '$1 == "cert" {print $2}' 2> /dev/null | sort -u`
    test -n "${CERT}" 2>&- && {
    CIPHERS=`tmsh list /ltm profile client-ssl ${PCRT} ciphers | grep ciphers | awk '{print $2}'`
    echo "${VAL} ${PCRT} ${CERT} ${CIPHERS}"
    }
    done
    }
    done
    echo "Virtual server count: ${VIRTS}"

    Note: To alter this script to search for server-ssl profile certificates, replace client-ssl with server-ssl and Ltm::ClientSSL Profile: with Ltm::ServerSSL Profile:.

  • Close the text editor saving the file cert-mapping that contains the bash script.
  • To execute the script type the following command:

    bash ./cert-mapping

Thansk in advance.

 

Best Regards,

 

 

  • Notepad isn't your best option. Are you able to save the file locally with notepad++

    Also, can you post a cat from the file?

    Command on the cli is cat /temp/cert-mapping