apt-key is deprecated

i want to remove a repository but every time i get the error "Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8))." ive tried updating apt-key and apt-get just to be sure but didnt solve the problem. please help.

like this command $ sudo apt-key del 7D8D08F6 .


Solution 1:

The answer is in the notice: Manage keyring files in trusted.gpg.d instead

So

cd /etc/apt/trusted.gpg.d/
rm {file}

where {file} needs to be replaced by the filename (7D8D08F6?) you want removed.

Solution 2:

You first need to find the keychain where the key with id 7D8D08F6 is stored:

for f in /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/*.{asc,gpg}; do
  $(gpg --list-keys --keyid-format short --no-default-keyring --keyring $f | fgrep -iq 7D8D08F6) && echo "Key 7D8D08F6 in $f"
done

and then delete this keyring:

sudo rm /etc/apt/trusted.gpg.d/<KEYRING>.gpg