我不再需要服务器密钥环中的密钥了。可以将其删除吗?我是使用以下命令添加的密钥:
谢谢你的帮助
curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add -
谢谢你的帮助
curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add -
/etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg
------------------------------------------------------
pub rsa4096 2012-05-11 [SC]
8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092
uid [ unknown] Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>
密钥ID将为EFE21092
sudo apt-key list
pub 1024R/B455BEF0 2010-07-29
uid Launchpad clicompanion-nightlies
sudo apt-key del <keyid>
,其中<keyid>
被实际要从密钥环中移除的密钥的keyid替代。$ sudo apt-key del B455BEF0
$ apt-key list | grep clicompan
$
pub rsa4096 2012-05-11 [SC] 8439 .... uid ....
- mxdsp/etc/apt/sources.list
文件中,在repo之前加上#
,然后重新运行sudo apt update
,在我的Ubuntu 18.04上有效。 - CoreyUbuntu 20.04 更新
运行后
sudo apt-key list
/etc/apt/trusted.gpg
--------------------
pub rsa4096 2016-04-12 [SC]
EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796
uid [ unknown] Google Inc. (Linux Packages Signing Authority) <linux-packages-keymaster@google.com>
sub rsa4096 2019-07-22 [S] [expires: 2022-07-21]
pub rsa4096 2017-04-11 [SC] [expired: 2019-09-28]
D4CC 8597 4C31 396B 18B3 6837 D615 560B A5C7 FF72
uid [ expired] Opera Software Archive Automatic Signing Key 2017 <packager@opera.com>
pub rsa4096 2019-09-12 [SC] [expires: 2021-09-11]
68E9 B2B0 3661 EE3C 44F7 0750 4B8E C3BA ABDC 4346
uid [ unknown] Opera Software Archive Automatic Signing Key 2019 <packager@opera.com>
sub rsa4096 2019-09-12 [E] [expires: 2021-09-11]
pub rsa4096 2017-03-13 [SC]
8CAE 012E BFAC 38B1 7A93 7CD8 C5E2 2450 0C12 89C0
uid [ unknown] TeamViewer GmbH (TeamViewer Linux 2017) <support@teamviewer.com>
sub rsa4096 2017-03-13 [E]
uid
下,您可以找到应用程序的名称,例如:[ unknown] Opera Software Archive Automatic Signing Key 2019 <packager@opera.com>
D4CC 8597 4C31 396B 18B3 6837 D615 560B A5C7 FF72 <-- THAT'S THE KEY
uid [ expired] Opera Software Archive Automatic Signing Key 2017 <packager@opera.com>
你可以通过将该键放在双引号或单引号中来删除它,就像这样:
sudo apt-key del "D4CC 8597 4C31 396B 18B3 6837 D615 560B A5C7 FF72"
pub 1024D/11F63C51 2002-02-28
uid Jamie Cameron <jcameron@webmin.com>
sub 1024g/1B24BE83 2002-02-28
sudo ./removeAptKey jcameron
KEYID: 11F63C51
OK
#!/bin/bash
function printKeys(){
echo "Installed keys are"
echo ""
sudo apt-key list
}
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [[ $# -eq 0 ]]
then
echo "No key name provided"
exit 1
fi
UNIQUE=$1
sudo apt-key list | grep "${UNIQUE}" -B 1 > result.temp
LENGTH=$(cat result.temp | wc -l)
if [[ ${LENGTH} -gt 2 ]]
then
echo "Attention you found more than 1 key. Use a more specific string."
printKeys
exit 2
fi
if [[ ${LENGTH} != 2 ]]
then
echo "Key not found. Doing nothing."
printKeys
exit 3
fi
KEYID=$(cat result.temp | grep 'pub' | cut -d " " -f 4 | cut -d "/" -f 2)
echo "KEYID: "$KEYID
apt-key del ${KEYID}
rm result.temp
apt-key del ${KEYID}
(在我的情况下是11F63C51
)rm result.temp
:不再需要这个文件了#
符号是罪魁祸首吗? - defuzed$#
,那么不是。它返回给定参数的数量。 - derHugoapt-key del $(apt-key list | awk 'NR=='$(apt-key list | grep --line-number --regexp "FOOBAR" | cut --fields 1 --delimiter ":")'{print;exit}' | awk '{print $2}' | cut --fields 2 --delimiter "/")
其中FOOBAR
是UID名称。
Ubuntu版本从16.10开始:
apt-key del $(apt-key list | awk 'NR=='`expr $(apt-key list | grep --line-number --regexp "FOOBAR" | cut --fields 1 --delimiter ":") - 1`'{print;exit}')
其中FOOBAR
是UID名称。
16.04
命令时出现了错误。awk: line 1: syntax error at or near {
但是尖括号是匹配的,所以我不确定为什么这个命令不能正常工作。 - Gabriel Fairapt-key list
的格式也发生了变化。现在看起来又可以工作了。(编辑:记得以超级用户身份运行此命令) - David Tabernero M.sudo apt-key list
sudo apt-key del "31CF B0B6 5659 B5D4 0DEE C98D DFA1 75A7 5104 960E"
sudo apt update
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DFA175A75104960E
apt-key del "$(gpg -n -q --import --import-options import-show mykey.asc | grep '^pub' -A 1 | tail -n 1 | xargs)"
gpg
命令,他们在here中给出了答案。apt update
。虽然我写这个答案已经有一段时间了。你收到了什么错误信息? - fakedad
sudo apt-key del "8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092"
,我认为使用整个指纹更安全,因为keyid可能会有重复(至少在使用PGP发送电子邮件时,我读到应该分享整个指纹而不仅仅是keyid)。 - baptx--help
列表之一(根本不清楚 id 是什么意思)。 - Amos Folarin