Last active
March 12, 2016 11:38
-
-
Save zshell31/4dd703dfa69be183775a to your computer and use it in GitHub Desktop.
Receive public keys for repositories for which public keys are not found by apt-get
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* For details: https://www.opennet.ru/base/sec/gpg_crypt.txt.html | |
* Also: http://f3arnil.blogspot.ru/2011/06/linux-apt-key.html | |
#!/bin/sh | |
KEY_SERVER=p80.pool.sks-keyservers.net | |
if [ -z $1 ] | |
then | |
KEYS='sudo apt-get -qq update 2>&1 | awk '/NO_PUBKEY/ {print($NF)}' | uniq | tr '\n' '\ '' | |
if [ -z $KEYS ] | |
then | |
echo "No missed public keys found." | |
else | |
echo "Missed public keys: $KEYS" | |
for KEY in $KEYS | |
do | |
sudo apt-key adv --recv-keys --keyserver $KEY_SERVER $KEY &&\ | |
echo "Public key $KEY has been added." | |
done | |
fi | |
else | |
KEYS='echo $@ | tr '\ ' '\n' | grep '\([[:alnum:]_]\|[a-fA-F]\)\{8,\}' | uniq | tr '\n' '\ '' | |
echo "Public keys to add: $KEYS" | |
for KEY in $KEYS | |
do | |
sudo apt-key adv --recv-keys --keyserver $KEY_SERVER $KEY > /dev/null &&\ | |
echo "Public key $KEY has been added." | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment