During the importing of the GnuPG key on our Debian system, we faced the following error. This is due to the minimal installation of our Debian servers. This tutorial will help you to fix “‘/usr/bin/dirmngr’: No such file or directory” error. This tutorial will help you to solve this on all Debian based Linux systems.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B

Executing: /tmp/apt-key-gpghome.1uzliCJjyg/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
gpg: connecting dirmngr at '/run/user/0/gnupg/d.9awoasrggmw7i87e3cdkmbgp/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr

Solution

You just need to install the dirmngr package on your system. Simply execute the following commands on terminal to install:

sudo apt update
sudo apt install dirmngr --install-recommends

After installing dirmngr package, again tried to import the GnuPG key and successfully imported it to our Debian system.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B

Executing: /tmp/apt-key-gpghome.UbN2VLG9LZ/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B
gpg: key 4B7C549A058F8B6B: public key "MongoDB 4.2 Release Signing Key " imported
gpg: Total number processed: 1
gpg:               imported: 1