Files
MOTD/70-vpn-keys
2021-09-08 01:52:43 +03:00

16 lines
547 B
Bash
Executable File

#!/bin/bash
CONFIG_DIR=/etc/openvpn/ca
echo ""
echo "List of OVPN keys:"
mapfile -t keys < <(sudo cat ${CONFIG_DIR}/pki/index.txt |grep ^V | grep -v server | grep -oh /CN=[[:alnum:]]* | sed -e 's/\/CN=//g')
out="Name, Expires\n"
for i in "${!keys[@]}"; do
IFS=" " read name <<< ${keys[i]}
out+="${name},"
out+=$(sudo cat ${CONFIG_DIR}/pki/issued/${name}.crt | grep ^' Not After :' | sed -e 's/ Not After :// ; s/ GMT//g ; s/:[0-9][0-9] / /')
out+="\n"
done
printf "$out" | column -ts $','
echo ""