Checking expiration date automatically

ERIC LANDES landes_eric at
Sat Jan 12 13:49:49 CET 2008


I use gnupg with a software I write and it needs a gpg key with expiration date. 
As I do not myself manage this software, I would like to provide a shell script on 
Linux (e.g. launched every day with cron) which would check for the expiration date and send 
a warning if key expires within a given time (15 days for example). 

Does there exist an option which would give the expiration date of a key, if such date exists ? 
I saw nothing on man gpg. 

It is possible to retrieve the expiration date on Linux with a 
command line, as shown below, but the command is ugly, not totally safe 
(because of the grep) and may not work on all versions of gpg. 

Having these keys : 
# LANG=C gpg --list-keys 
pub   1024D/E5F2C00E 2008-01-12 [expires: 2009-01-11]
uid                  test date (test) <test at date>
sub   2048g/7C17580B 2008-01-12 [expires: 2009-01-11]

pub   1024D/16B870A6 2008-01-12
uid                  aaaaaa (fdsfsd) <a at a.a>
sub   2048g/B2526B84 2008-01-12

Expiration date of key test at date is : 
# LANG=C gpg --list-keys test at date | grep "\[expires:" | cut -d ":" -f 2 | cut -d " " -f 2 | cut -d "]" -f 1 | head -n 1


 Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20080112/952bb02a/attachment.htm>

More information about the Gnupg-users mailing list