I wrote a small script monitor my TLS certificates expiration.

The following is the output when I run /etc/update-motd.d/05-ssl in the terminal. The permissions on the script is 633 root

TLS certs             Valid until
● facebook.com    Thu Jun 06 2019
● google.com      Tue Jun 18 2019

However when I log in via ssh my MOTD only shows

TLS certs        Valid until

I suspect this is related to the piping I am doing in the last line when I print the output.


ssl_domains="facebook.com google.com"
currentTime=$(date +%s)
output="TLS certs|      Valid until"

for domain in $ssl_domains; do
    certTime=$(openssl s_client -servername ${domain} -connect ${domain}:443 < /dev/null 2>/dev/null | openssl x509 -noout -enddate 2>/dev/null | cut -d= -f2)
    certLineTime=$(date -d "${certTime}" +"%a %b %d %Y")

    certTimestamp=$(date -d "${certTime}" +%s)
    if [ "${certTimestamp}" -ge "${currentTime}" ]; then

    output+="\n$sign $domain|  $certLineTime"

echo -e "$output" | column -t -s '|'

1 Answers

jamiees2 On Best Solutions

Try adding

export LANG='en_US.UTF-8'

at the top of your script.