Search code examples
cassandraaptkeyring

Cassandra keyring issue


I am installing cassandra following the steps in the official website coming to the step of sudo apt-get update I got this

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
W: The key(s) in the keyring /etc/apt/trusted.gpg are ignored as the file has an unsupported filetype.

I tried several times with several methods to export a key or multiple ones but I got the nothing exported response can anyone help me solve this please.


Solution

  • I'm going to guess that you're using Ubuntu with a version > 22. It looks like apt-key has been deprecated, which means that apt-get can't use the existing keys in the old format to get out to its repositories. It has been replaced with the gpg command, which requires the gpg keys to be in a different location and format.

    A more thorough description of this problem can be found in this article - Ubuntu: apt-key is deprecated

    tl;dr;

    To fix this, we need to move the current GPG public keys from the file /etc/apt/trusted.gpg and the folder /etc/apt/trusted.gpg.d/ to /etc/apt/keyrings/ with the correct format.

    Here is a quick synapsis of one of the steps from the article, about 2/3 of the way down:

    Identify the keys to migrate with:

    $ apt-key list
    Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
    /etc/apt/trusted.gpg
    --------------------
    pub   dsa1024 2007-03-08 [SC]
          4CCA 1EAF 950C EE4A B839  76DC A040 830F 7FAC 5991
    uid           [ unknown] Google, Inc. Linux Package Signing Key <[email protected]>
    sub   elg2048 2007-03-08 [E]
    
    pub   rsa4096 2016-04-12 [SC]
          EB4C 1BFD 4F04 2F6D DDCC  EC91 7721 F63B D38B 4796
    uid           [ unknown] Google Inc. (Linux Packages Signing Authority) <[email protected]>
    sub   rsa4096 2021-10-26 [S] [expires: 2024-10-25]
    sub   rsa4096 2023-02-15 [S] [expires: 2026-02-14]
    These 2 keys can be migrated into the same file:
    
    sudo mkdir -p /etc/apt/trusted.gpg.d && \
    sudo apt-key export -o /etc/apt/trusted.gpg.d/google.asc \
    D38B4796 7FAC5991
    

    The migration can be done in one command with:

    sudo apt-key export D38B4796 7FAC5991 | sudo gpg --dearmour -o /etc/apt/keyrings/google.gpg
    

    However, 2 steps may be preferable. Also the key 7FAC5991 is obsolete and could be deleted.

    Now explore the format of the created file:

    $ file /etc/apt/trusted.gpg.d/google.asc
    /etc/apt/trusted.gpg.d/google.asc: PGP public 
    key block Public-Key (old)
    

    The format is the old textual format PGP ASCII-Armor, we need to export it in a binary format OpenPGP supported by gpg and move it to the right folder:

    sudo mkdir -p /etc/apt/keyrings/ \
    && cat /etc/apt/trusted.gpg.d/google.asc \
    | sudo gpg --dearmour -o /etc/apt/keyrings/google-chrome.gpg
    

    Now the format is correct:

    $ file /etc/apt/keyrings/google.gpg
    /etc/apt/keyrings/google.gpg: OpenPGP Public Key Version 4, 
    Created Thu Mar  8 20:17:10 2007, DSA (1024 bits); User ID; Signature; 
    OpenPGP Certificate
    

    You can remove the public keys with:

    sudo apt-key del D38B4796 7FAC5991
    

    Give the article a read. This way the instructions will make more sense as you go through them.