我们应该在这里添加一些密钥"curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -"?



我正试图在ubuntu上安装docker,根据安装指南,我发现了这个命令。

"curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -"

在它的回应中,我得到了肯定,没有什么真正的下载。我想提供一个密钥吗?或者这个curl命令的目的是什么。

apt-key add为docker存储库添加了一个受信任的密钥。curl命令正在下载该密钥,并将其管道传输到apt-key add命令,后者将其添加为受信任密钥。

>man apt-key
COMMANDS
Add filename
Add a new key to the list of trusted keys. The key is read from the filename 
given with the parameter filename or if the filename is - from standard 
input.
It is critical that keys added manually via apt-key are verified to belong 
to the owner of the repositories they claim to be for otherwise the apt-
secure(8) infrastructure is completely undermined.

简而言之,此命令下载密钥并将其添加为受信任密钥。

我用另一种方式来理解!

1.存储的文件密钥

#curl -fsSL https://download.docker.com/linux/debian/gpg > key_stored2file

2.将新密钥添加到受信任密钥列表中

#apt-key add key_stored2file
OK

如果给定了-而不是文件名(在上面的示例中为key_stored2file),则它将取自标准输入,因此它可以作为单个命令运行,如下所示

#curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - 

最新更新