Skip to content

Adding missing GPG keys for apt-get on WSL

Sébastien Dubois /

1 min read

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? ;-)

About Sébastien

Hello everyone! I'm Sébastien Dubois. I'm an author, founder, and CTO. I write books and articles about software development & IT, personal knowledge management, personal organization, and productivity. I also craft lovely digital products 🚀

If you've enjoyed this article and want to read more like this, then subscribe to my newsletter, check out my PKM Library and my collection of books about software development 🔥.

You can follow me on Twitter 🐦

If you want to discuss, then don't hesitate to join one of my communities: the Software Crafters community, the Personal Knowledge Management community, and the focusd Productivity community
Subscribe to my newsletter
Weekly newsletter discussing personal knowledge management, software development, building in public and productivity