In this case, list the keys with this command:
sudo apt-key list
There should be a way to identify the repository. You should have its name or developers name.
In my case, I am handling the Spotify repository:
abhishek@itsfoss:~$ sudo apt-key list [sudo] password for abhishek: Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key%%(8)%%). /etc/apt/trusted.gpg -------------------- pub rsa4096 2021-10-27 [SC] [expires: 2023-01-20] F9A2 1197 6ED6 62F0 0E59 361E 5E3C 45D7 B312 C643 uid [ unknown] Spotify Public Repository Signing Key <tux@spotify.com>
Copy the last 8 characters of the second line under pub. In my case, it is B312 C643
. You’ll have to remove the space between the numbers and use it like this:
sudo apt-key export B312C643 | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/spotify.gpg
The output file could be named anything but it is better to use a name that is associated with the package or repository.
The gpg –dearmour
part is important because the mechanism expects you to have the keys in binary format.