我如何绕过/忽略 apt 的 gpg 签名检查?

我如何绕过/忽略 apt 的 gpg 签名检查?

我访问的所有密钥服务器都超时了。我需要在不检查公钥签名的情况下安装软件包。有没有办法绕过所有签名检查/忽略所有签名错误或欺骗 apt 认为签名已通过?

我非常清楚这样做很危险

答案1

将选项传递--allow-unauthenticatedapt-get如下内容:

sudo apt-get --allow-unauthenticated upgrade

来自以下手册页apt-get

--allow-unauthenticated
如果软件包无法通过身份验证,则忽略此情况,并且不提示。这对于 pbuilder 等工具很有用。配置项:APT::Get::AllowUnauthenticated。

您可以使用/etc/apt/apt.conf.d/dir 中的自己的配置文件使此设置永久生效。文件名可以是99myown,并且可能包含以下行:

APT::Get::AllowUnauthenticated "true";

这样,您不需要每次安装软件时都使用该选项。注意:我不建议默认设置此选项,它会绕过可能允许对手危害您的计算机的签名检查。

答案2

如果您尝试从打包密钥的存储库中获取包并将其包含在存储库中而不包含在其他任何地方,则使用 dpkg 下载和安装密钥/密钥环包可能会非常烦人,并且很难以易于编写脚本和可重复的方式进行操作。

如果您可以从密钥服务器安装密钥或者通过 https 从受信任的来源下载密钥,则不建议使用以下脚本,但如果您没有其他方法,则可以使用此脚本。

echo "deb http://your.repo.domain/repository/ $(lsb_release -c -s) universe" | sudo tee /etc/apt/sources.list.d/your-repo-name.list

sudo apt -o Acquire::AllowInsecureRepositories=true \
-o Acquire::AllowDowngradeToInsecureRepositories=true \
update

## if the 'apt update' above fails it is likely due to previously
## having the GPG key and repository on the system, you can clean
## out the old lists with `sudo rm /var/lib/apt/lists/your.repo.domain*`

apt-get -o APT::Get::AllowUnauthenticated=true install repo-keyring-pkgname

## If you ever run `sudo apt-key del your-repos-keyID`
## you may have to `sudo apt remove --purge repo-keyring-pkgname`
## Update should run without the GPG warnings now that the key is installed

apt-get update
apt-get install somepkg-from-repo

我最初将它们放在一起是因为 i3 在他们的 sur5r repo 中这样做,但后来我发现他们的密钥在 keyserver.ubuntu.com 列表中,所以我可以避免sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E3CA1A89941C42E6所有额外的包麻烦。

答案3

我在使用旧的 Debian 服务器时遇到了同样的问题。我甚至无法

apt-get update

这给了我以下错误:

E: Release file expired, ignoring http://archive.debian.org/debian/dists/squeeze-lts/Release (invalid since 1183d 0h 2min 51s)

最后的解决方案是添加以下内容:

Acquire::Check-Valid-Until false;

到 /etc/apt/apt.conf(如果不存在则创建)。此后,错误变成了简单的警告。

我猜它也许可以在 ubuntu 上运行。

请注意,这虽然有点不安全,但仍然比禁用签名检查更安全。

答案4

/etc/apt/apt.conf.d/99allow_unauth使用此内容创建:

APT { Get { AllowUnauthenticated "1"; }; };

谢谢php-coder评论

在 sources.list 文件中使用此语法也可能有帮助:

deb [ allow-insecure=yes ] http...

相关内容