Forum archive
When updating vm nextcloud v 15.1 error
When executing a command
apt-get update
error
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.sury.org/php stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B188E2B695BD4743 W: Failed to fetch https://packages.sury.org/php/dists/stretch/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B188E2B695BD4743 W: Some index files failed to download. They have been ignored, or old ones used instead.
How to fix ?
You are absolutely correct. Good work and thanks for sharing.
However, I can't help myself. Let me share a couple of tips...
You can use grep to check for both the existence of sury.org in the sources.lists and whether or not it's locked to the specific key file, using grep. I.e.:
Grep searches for strings within files. In this case, it will search recursively (the '-r' switch) for the string 'sury.org' (enclose in quotes if it contains spaces) in all files that match the glob: '/etc/apt/sources.list*'. The asterisk ('*') expands to match any 0 or more characters, so will match '/etc/apt/sources.list' (if it exists and) all the files in '/etc/apt/sources.list.d/'. It will return all matches in the form "<filename:> <line_that_matches>". E.g. you might get something like this (where the sources list file is "/etc/apt/sources.list.d/php.list" & the key file is "/etc/apt/sources.list.d/php.list"):
Also, out of interest, even if the repo is locked to the specific key (i.e. you have the 'signed-by' bit as per above) you can still use 'apt-key' to update the key. You just need to specify the keyfile (via '--keyring' switch):
FWIW it's generally preferable to use 'apt-key' like that. Sometimes keys can be in the text aka ASCII aka armoured format, rather than the binary GPG format (as the sury.org key is). Trying to use armoured keys with apt will fail. FYI armoured keys often have an '.asc' file extension, although sometimes '.txt' (or perhaps even something else). The apt-key command will copy a GPG key file straight in; or convert an armoured key file on the fly.