Create ubuntu.md

This commit is contained in:
t. Macleod Sawyer 2021-04-15 03:07:45 -05:00 committed by GitHub
parent 71c1f1913e
commit a25a718c01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

15
ubuntu.md Normal file
View file

@ -0,0 +1,15 @@
# Ubuntu
## Batch import all missing GPG keys
Solves issues with GPG keys on major OS updates by grabbing and replacing **all** missing creds from the keyserver.
There's no need to change any part of the command, just run it as is.
The command runs `sudo apt update` to update your software sources and detect missing GPG keys, then imports each missing key using [hkp://pool.sks-keyservers.net:80](https://sks-keyservers.net/) as its server, you could change this to any keyserver you feel most comfortable with ([http://keyserver.ubuntu.com](keyserver.ubuntu.com) is a possibility, but I've always had issues with it).
The command also uses an array to store missing GPG keys for which we've already imported the key. Without that, the key import command would run twice for each missing key.
```bash
sudo apt update 2>&1 1>/dev/null | sed -ne 's/.*NO_PUBKEY //p' | while read key; do if ! [[ ${keys[*]} =~ "$key" ]]; then sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys "$key"; keys+=("$key"); fi; done
```