apt-key: command not found

apt-key is a command-line utility that is used to manage the authentication keys that are used to authenticate packages. It is a part of the apt package manager, which is used to manage packages on Debian-based systems.

The apt-key command is used to manage the authentication keys that are used to authenticate packages. These keys are used to verify the integrity and authenticity of the packages that are installed on the system.

Some of the common options for the apt-key command include:

  • add: Add a new key to the keyring.
  • adv: Run an advanced key server command.
  • del: Remove a key from the keyring.
  • export: Export one or more keys from the keyring.
  • import: Import one or more keys into the keyring.
  • list: List the keys in the keyring.

Here is an example of how apt-key can be used to add a new key to the keyring:

# apt-key add /path/to/key.asc

This command adds the key stored in the file /path/to/key.asc to the keyring. The key can then be used to authenticate packages. You can learn more about the apt-key command and its options by reading the apt-key man page or by typing apt-key –help at the command prompt.

If you encounter the below error while running the apt-key command:

apt-key: command not found

you may try installing the below package as per your choice of distribution:

OS Distribution Command
Debian apt-get install apt
Ubuntu apt-get install apt
Kali Linux apt-get install apt
Fedora dnf install apt
Raspbian apt-get install apt

apt-key Command Examples

1. List trusted keys:

# apt-key list

2. Add a key to the trusted keystore:

# apt-key add {{public_key_file.asc}}

3. Delete a key from the trusted keystore:

# apt-key del {{key_id}}

4. Add a remote key to the trusted keystore:

# wget -qO - {{https://host.tld/filename.key}} | apt-key add -

5. Add a key from keyserver with only key id:

# apt-key adv --keyserver {{pgp.mit.edu}} --recv {{KEYID}}
Related Post