I agree with @Ken_Town ,

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8))

apt-key stores all keys in a single /etc/apt/trusted.gpg which seems to have its own issues (thus deprecated). It embeds to this file the .asc key files created with gpg --armor

the suggested way to store key files is to store .gpg files under /etc/apt/trusted.gpg.d/. if we have .asc file then gpg --dearmor takes its content and gives back .gpg content.

unless we are supplied directly with .gpg file by MongoDB (so be careful in the future), it is better to use

curl -sS https://pgp.mongodb.com/server-6.0.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/mongodb-6.0.gpg
or
wget -qO - https://pgp.mongodb.com/server-6.0.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/mongodb-6.0.gpg

PS: use apt-key list and see any key under /etc/apt/trusted.gpg. use apt-key remove to remove those if you want, and add again with the above method.

1 Like