gpg: can't connect to the agent: IPC connect call failed (WSL Ubuntu 20.04)

13,032

Solution 1

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

Solution 2

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

sudo apt remove gpg

sudo apt install gnupg1
Share:
13,032

Related videos on Youtube

Dmitriy Lyutov
Author by

Dmitriy Lyutov

Updated on September 18, 2022

Comments

  • Dmitriy Lyutov
    Dmitriy Lyutov over 1 year

    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
    
  • Feodor Fitsner
    Feodor Fitsner about 4 years
    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.
  • Dmitriy Lyutov
    Dmitriy Lyutov about 4 years
    Thank you! It's also possible to copy a key to folder /etc/apt/trusted.gpg.d/ manually
  • ijustlovemath
    ijustlovemath about 4 years
    @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!
  • GPHemsley
    GPHemsley almost 4 years
    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 -
  • Param Siddharth
    Param Siddharth almost 4 years
    That does the job. Thank you!
  • DISMGMT
    DISMGMT over 3 years
    Thanks, that worked for me too.