确保 add-apt-repository 保持 deb 输入字符串中的 trust=yes

heu*_*cus 5 apt 18.04

sources.list我正在尝试使用该命令将私有存储库添加到我的存储库中add-apt-repository,但我无权访问与该包存储库对应的公钥。

如果我尝试正常添加存储库

sudo add-apt-repository "deb http://my-private-server.test $(lsb_release -s -c) main"
Run Code Online (Sandbox Code Playgroud)

我遇到公钥不可用的问题(如我所料)

  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <pubkey>
Reading package lists... Done                                                                            
W: GPG error: https://my-private-server.test bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <pubkey>
E: The repository 'http://my-private-server.test bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Run Code Online (Sandbox Code Playgroud)

我想标记我信任该存储库,但如果我尝试添加[trusted=yes]已添加的存储库,如果我查看我的sources.list,它已从条目中删除。

sudo add-apt-repository "deb [trusted=yes] http://my-private-server.test $(lsb_release -s -c) main"
tail /etc/apt/sources.list
deb http://my-private-server.test bionic main
# deb-src http://my-private-server bionic main
Run Code Online (Sandbox Code Playgroud)

如果我添加[arch=amd64]而不是[trusted=yes],它会正确显示在 中sources.list。如果我手动添加[trusted=yes]sources.list来自未签名的存储库的错误,则不再出现,但我不想手动编辑该文件。

添加可信存储库的正确方法是什么add-apt-repository