Forum Discussion

Mchelle_181998's avatar
Oct 20, 2017
Solved

report for all SSL

Looking how to create a more formatted report of all SSL certificates

 

I run command tmsh list sys file ssl-cert all > /ssl.txt which then I import into excel. However the ssl.txt each ssl certificate components (expiry date, serial , etc) is listed in rows there is no delimiter. I would like each row of information listed in columns

 

  • How would I put this to an output text file

     

    !/bin/bash

    PARTITIONS=( $(tmsh list auth partition one-line | sed -e 's/ //g' | grep -oP '(?<=partition)[^{]+' -) )

     

    for partition in ${PARTITIONS[*]}; do tmsh -q -c "cd /$partition; list sys file ssl-cert" done

     

9 Replies

  • Kevin_K_51432's avatar
    Kevin_K_51432
    Historic F5 Account

    Greetings,

    This should do the trick:
    tmsh -c "cd /; list sys file ssl-cert /*/*" > /ssl.txt
    

    Kevin

  • How would I put this to an output text file

     

    !/bin/bash

    PARTITIONS=( $(tmsh list auth partition one-line | sed -e 's/ //g' | grep -oP '(?<=partition)[^{]+' -) )

     

    for partition in ${PARTITIONS[*]}; do tmsh -q -c "cd /$partition; list sys file ssl-cert" done

     

  • Kevin_K_51432's avatar
    Kevin_K_51432
    Historic F5 Account

    Greetings,

    You'll need to output this using the "one-line" option. Then using awk, extract each interesting column.

    The $ represents the position within the column (minus one).

    I'm extracting those mentioned in the description:

    tmsh -c "cd /; list sys file ssl-cert /*/* one-line" | awk '{print $4, $6, $7, $14, $15, $32, $33}'
    Common/mykey2.crt certificate-key-size 2048 expiration-date 1542902160 serial-number 249033360
    Common/mykey3.crt certificate-key-size 2048 expiration-date 1542902167 serial-number 249033367
    Common/mykey4.crt certificate-key-size 2048 expiration-date 1542902173 serial-number 249033373
    Common/mykey.crt certificate-key-size 2048 expiration-date 1542901585 serial-number 249032785
    

    Try running the command without the "| awk" filter to see the columns and then count over (minus one).

    Hope this makes sense and is helpful!

    Kevin
  • this is the command I'm using tmsh -c "cd /; list sys file ssl-cert // one-line" /SSLreports/newssl.txt

     

    it doesn't work getting an error

     

    tmsh An option may be specified once. A command may follow the options, in which case the shell exits after executing the command.

     

  • Kevin_K_51432's avatar
    Kevin_K_51432
    Historic F5 Account

    It looks like you're missing the redirect (>) after the (one-line"). This is used to redirect the output to a file. So give this a try:

    tmsh -c "cd /; list sys file ssl-cert /*/* one-line" > /SSLreports/newssl.txt