Created
December 5, 2022 10:59
-
-
Save eusonlito/e8d547ebf039be5f1bba10233f75005b to your computer and use it in GitHub Desktop.
Batch migration from /etc/apt/trusted.gpg to custom keyring
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
#!/bin/bash | |
for KEY in $(apt-key --keyring /etc/apt/trusted.gpg list | grep -E "(([ ]{1,2}(([0-9A-F]{4}))){10})" | tr -d " " | grep -E "([0-9A-F]){8}\b" ); do K=${KEY:(-8)}; apt-key export $K | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/imported-from-trusted-gpg-$K.gpg; done |
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
Came across this problem after moving to Ubuntu 22.04 and wanted to add my solution. I had a lot of keys that needed to be updated/converted. This is not an optimal solution, but works well. | |
This solution is specific to Ubuntu 22.04, with bash 5.2.16. Other distributions and versions may not work. | |
A one-liner to convert all those deprecated keys to the new format. | |
PLEASE TAKE THE TIME TO UNDERSTAND WHAT YOUR DOING HERE BEFORE RUNNING IT!! Also make sure your bash is not too old. My bash version: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) | |
Source: https://askubuntu.com/a/1415702 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment