140

While trying to receive keys in my Debian Stretch server, I get this error:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF Executing: /tmp/apt-key-gpghome.4B7hWtn7Rm/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory gpg: connecting dirmngr at '/tmp/apt-key-gpghome.4B7hWtn7Rm/S.dirmngr' failed: No such file or directory gpg: keyserver receive failed: No dirmngr 
1

3 Answers 3

192

Installing the package dirmngr fixed the error.

user@debian-server:~$ sudo apt-get install dirmngr 

Retrying :

user@debian-server:~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF Executing: /tmp/apt-key-gpghome.haKuPppywi/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF gpg: key A6A19B38D3D831EF: public key "Xamarin Public Jenkins (auto-signing) <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 
5
  • 6
    Had same problem on Debian 9.4. Installing dirmngr fixed it. Commented Mar 14, 2018 at 23:11
  • 1
    I got the same error of the OP, but I already have latest gpg installed. Commented Aug 2, 2018 at 5:04
  • 1
    installing gpg fixed it for me on a Debian 9.3. dirmngr was already installed. Commented Aug 23, 2018 at 11:56
  • Same issue on Raspbian 9.8 stretch. Installing dirmngr resolved it. Thanks. Commented Mar 11, 2019 at 4:58
  • 6
    I found that it was because I'd never used gpg before. sudo apt-install gpg if it isn't installed already - then run sudo gpg -k to create the dirmgr directory and try again. Commented Jul 28, 2022 at 13:38
11

I wasn't able to get dirmngr to work, but you can also just import the key directly using apt-key add. The GPG public key is often listed at the root of the repo like http://origin-download.mono-project.com/repo/

curl https://origin-download.mono-project.com/repo/xamarin.gpg | sudo apt-key add - 
3
  • 2
    You need to run dirmngr if it's not already running. Commented Oct 3, 2018 at 19:54
  • dirmngr was running, but still no joy... If the keyserver happens to be keyserver.ubuntu.com then you can access via a browser and search for the public key using the --recv-keys parameter, then simply use apt-key add as per this answer Commented Mar 18, 2019 at 12:22
  • Following this answer, I managed to download a .asc file from keyserver.ubuntu.com, then to import it with sudo gpg --no-default-keyring --keyring /etc/apt/keyrings/<YOUR-APP>.gpg --import armored-keys.asc Commented Jan 11, 2024 at 15:53
1

As said, the dirmngr package should be installed, but it may happen that apt does not work and cannot install any package. Don't worry. Search dirmngr package on https://packages.debian.org selecting your distribution version, download it on the linux machine and install it using dpkg command, for example:

cd /tmp wget http://ftp.it.debian.org/debian/pool/main/g/gnupg2/dirmngr_2.1.18-8~deb9u4_amd64.deb sudo dpkg -i dirmngr_2.1.18-8~deb9u4_amd64.deb 

Then you'll be able to run apt-key command to fetch the missing keys.

1
  • This allowed me to rescue and update my very old Debian Stretch install, after manually finding all the dependencies to install manually. Commented Jul 29, 2024 at 7:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.