8

after updating WSL Ubuntu i can't do sudo apt-key add with an error:

gpg: can't connect to the agent: IPC connect call failed

2 Answers 2

9

Uninstall the gpg that comes installed by default and install gnupg1 package instead

sudo apt remove gpg

sudo apt install gnupg1
2
  • 1
    That does the job. Thank you! Aug 9, 2020 at 7:50
  • Thanks, that worked for me too.
    – Doomd
    Aug 30, 2020 at 22:24
3

This appears to be a known bug in WSL. You can try adding the key manually using:

curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=YOUR_KEY_HERE" | sudo apt-key add

YOUR_KEY_HERE is the GPG key the package you need wants to install. An example would be: 0xA6A19B38D3D831EF

4
  • 1
    That bug is for Ubuntu 18.04 WSL, but I never had such issues in 18.04. 20.04 is failing out of the box. Apr 25, 2020 at 4:27
  • 1
    Thank you! It's also possible to copy a key to folder /etc/apt/trusted.gpg.d/ manually Apr 25, 2020 at 4:53
  • @DmitriyLyutov that's not recommended, as apt does not keep track of manually added keys. Use the package management utilities whenever you can to keep things maintainable! Apr 25, 2020 at 15:32
  • 2
    This solution didn't work for me, but you can extract the keyid from this output: curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg -vv --dry-run --import -
    – GPHemsley
    Jun 25, 2020 at 17:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .