替换 apt-key 导入私有公钥 在使用 apt-key 导入私钥时会遇到以下警告: Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead 将密钥添加到 /etc/apt/trusted.gpg.d 是不安全的,因为它会为所有存储库添加密钥。这正是 apt-key 必须

替换 apt-key 导入私有公钥

在使用 apt-key 导入私钥时会遇到以下警告:

1
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead

将密钥添加到 /etc/apt/trusted.gpg.d 是不安全的,因为它会为所有存储库添加密钥。这正是 apt-key 必须被弃用的原因。

为了避免该问题,下面提供一种快速且安全的导入私有公钥的方法:

1
2
3
4
5
6
7
8
9
10
sudo mkdir -p /etc/apt/keyrings/
wget -O- https://example.com/EXAMPLE.gpg |
gpg --dearmor |
sudo tee /etc/apt/keyrings/EXAMPLE.gpg > /dev/null

echo "deb [signed-by=/etc/apt/keyrings/EXAMPLE.gpg] https://example.com/apt stable main" |
sudo tee /etc/apt/sources.list.d/EXAMPLE.list

# Optional (you can find the email address / ID using `apt-key list`)
sudo apt-key del support@example.com

References