gpg: No keyserver available [closed]
Asked Answered
R

3

8

on my server i try to get the keys and execute the command

gpg --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F

but I get that the server is not available

gpg: keyserver receive failed: No keyserver available

but when i do the same on my local machine everything works fine.the key is imported. help me pls dns is the same on the server and on my local computer. difference in versions of gpg and dirmngr on local 2.2.12 on server 2.2.4 Ubuntu 18.04

Redmund answered 27/9, 2021 at 10:20 Comment(1)
Just download key manually from keyserver.ubuntu.com:11371 search web interface and add it with command cat 0123456789key.asc | sudo apt-key add -Cadell
R
8

it worked for me

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 34893610CEAA9512

you can use script

#!/bin/bash

declare -a keyservers=(
    "hkp://keyserver.ubuntu.com:80"
    "keyserver.ubuntu.com"
    "ha.pool.sks-keyservers.net"
    "hkp://ha.pool.sks-keyservers.net:80"
    "p80.pool.sks-keyservers.net"
    "hkp://p80.pool.sks-keyservers.net:80"
    "pgp.mit.edu"
    "hkp://pgp.mit.edu:80"
)

keys=$(apt update 2>&1 | grep -o '[0-9A-Z]\{16\}$')

for key in $keys; do
    for server in "${keyservers[@]}"; do
        echo "Fetching GPG key ${key} from ${server}"
        apt-key adv --keyserver $server --keyserver-options timeout=10 --recv-keys ${key}
        if [ $? -eq 0 ]; then
            echo "Key '${key}' successful added from server '${server}'"
            break
        else
            echo "Failed add key '${key}' from server '${server}'. Try another server"
            continue
        fi
    done
done
Redmund answered 28/9, 2021 at 9:2 Comment(2)
In my case, I set the keys variable like this: keys=$(apt update 2>&1 |grep "GPG error" | awk '{ print $13 }') The ERROR msg look like this: bash W: GPG error: https://my.server.domain/artifactory/Hashicorp-apt-repo-key jammy InRelease: The following signatures were invalid: REVKEYSIG DA418C88A3219F7B HashiCorp Security (HashiCorp Package Signing) <[email protected]> Eldredge
gpg: keyserver receive failed: Server indicated a failure for all serversCadell
W
0

Looks like you have network access issue or environment issue. This command works fine for me. GPG and Ubuntu versions, which I'm using:

gpg --version | head -2; lsb_release -d
gpg (GnuPG) 2.2.19
libgcrypt 1.8.5
Description:    Ubuntu 20.04.3 LTS

Try to access keyserver.ubuntu.com via curl and see what happens

curl http://keyserver.ubuntu.com | & grep description
      <meta name="description" content="OpenPGP Keyserver">
Washery answered 27/9, 2021 at 11:40 Comment(0)
S
-2

just disconnect your wifi and then again connect. It worked for me.

Sandglass answered 21/12, 2022 at 7:39 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Terrie

© 2022 - 2024 — McMap. All rights reserved.