Adding missing GPG keys for apt-get on WSL

How to add missing GPG keys when using WSL

GnuPG logo: blue padlock with wordmark, the tool for managing GPG keys

TL;DR: Retrieve the keys manually using:

curl -sL “https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xKEY_HASH_GOES_HERE" | sudo apt-key add

Recently, I’ve stumbled upon an issue where some GPG keys were not available. Usually the solution to that is to directly use apt-key to retrieve those keys.

For example:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A

Unfortunately (at least on my version of WSL), there seems to be an issue with it; the command fails with:

...
gpg: connecting dirmngr at ‘/tmp/apt-key-gpghome.H755AH9Xn5/S.dirmngr’ failed: IPC connect call failed
gpg: keyserver receive failed: No dirmngr

Obviously, installing dirmngr should fix it but it doesn’t work once installed.

Since I don’t really have time to get into this further (I’m pretty sure that there are known solutions to this under WSL: https://github.com/sbt/sbt/issues/4261), I looked for alternatives.

I found the following:

curl -sL “https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xKEY_HASH_GOES_HERE" | sudo apt-key add

Basically we’re just downloading the key ourselves using curl and passing it to apt-key so that it can add it.

Time to get back to what I was trying to do in the first place.. What was it already? ;-)


Go Further

How to install and configure GPG
A detailed guide on how to install and configure GPG/PGP.
How to build a Product: From idea to code
How to go from an idea to an actual product. A story about product development
How to use Tailwind with Svelte and Nrwl NX
Learn how to use Tailwind with Svelte and Nrwl NX

Want to go deeper?

Knowii Community - Master Knowledge Management + AI | From €4.99/month
Join 400+ members mastering Knowledge Management AND AI. Community + Courses + Tools integrated. €500+ value in Knowledge Master tier.

About Sébastien

I'm Sébastien Dubois, and I'm on a mission to help knowledge workers escape information overload. After 20+ years in IT and seeing too many brilliant minds drowning in digital chaos, I've decided to help people build systems that actually work. Through the Knowii Community, my courses, products & services and my Website/Newsletter, I share practical and battle-tested systems.

I write about Knowledge Work, Personal Knowledge Management, Note-taking, Lifelong Learning, Personal Organization, Productivity, and more. I also craft lovely digital products and tools.

If you want to follow my work, then become a member and join our community.

Ready to get to the next level?

If you're tired of information overwhelm and ready to build a reliable knowledge system:

Found this valuable? Share it with someone who needs it.

Join 6,000+ readers. Get practical systems for knowledge & AI. Free.

Subscribe ✨

Free: Knowledge System Checklist

A clear roadmap to building your own knowledge system. Subscribe and get it straight to your inbox.

6,000+ readers. No spam. Unsubscribe anytime.