Thursday, October 26, 2017

Update Ubuntu expired keys

Update all expired keys from Ubuntu key server in one command
sudo apt-key list | \
 grep "expired: " | \
 sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' | \
 xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys
Command explanation:
  1. sudo apt-key list - lists all keys installed in the system;
  2. grep "expired: " - leave only lines with expired keys;
  3. sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' - extracts keys;
  4. xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys - updates keys from Ubuntu key server by found expired ones.

No comments :

Post a Comment