I am working with SSH certificates. I would like to do an automatic renew of them shortly before they expire. Not quite sure yet how the renewal will work, but I already found out how I can check the number of remaining days the certificate is valid:
|
|
For an example:
|
|
- The first line of the script collects only this
Valid:
line and extracts the last date in it. - The next line converts this extracted date into seconds since the epoch.
- Next, I also collect the seconds since the epoch for “now”.
- Finally, I subtract those both timestamps and do a division by $86400 = 24 \cdot 60 \cdot 60$. That way, I get the number of days this certificate is still valid.
At the time of writing, we have April 10th, 2024. The certificate is valid until April 27th, 2024, so we get $17$ days of remaining validity.
My idea now is something like the following:
|
|