Ubuntu 18.04 add gpg key failed with gpg-agent not found error

Rui Yang picture Rui Yang · May 13, 2018 · Viewed 14.3k times · Source

trying to migrate our base image to the stable Ubuntu 18.04, when we try to add our gpg key, getting this error:

root@77ff14f29cab:/# apt-key add apt-key.gpg 
gpg: failed to start agent '/usr/bin/gpg-agent': No such file or directory
gpg: can't connect to the agent: No such file or directory
gpg: failed to start agent '/usr/bin/gpg-agent': No such file or directory
gpg: can't connect to the agent: No such file or directory

Answer

user2849211 picture user2849211 · May 13, 2018

You're missing the gpg-agent package, most likely:

gpg-agent/testing,unstable,now 2.2.5-1 amd64 [installed,automatic]
  GNU privacy guard - cryptographic agent

The command you should run is apt install gpg-agent.