Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Just stumbled over this closed thread here: GPG Error while running apt-get

Same problem here, Ubuntu 12.04 behind a firewall and proxy.

I dont think that matter is duplicate of the given topic. So i reopen this matter in this thread.

My output:

root@musik-Aspire-7741:~# apt-key adv --keyserver hkp:// --recv-keys 58B98E87
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-  keyring /tmp/tmp.tWVMhyIMYh --trustdb-name /etc/apt/trustdb.gpg --keyring     /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver     hkp:// --recv-keys 58B98E87
gpg: Key 58B98E87 of hkp Server request
?: Connection refused
gpgkeys: HTTP fetch error 7: couldn't connect: Connection refused
gpg: No valid OpenPGP data found.
gpg: Total number processed: 0

Conclusion: gpg is not working with hkp:// via http.

share|improve this question
If you have to go through a proxy, you need to tell GPG to use the proxy. Do you have http_proxy set? (echo $http_proxy) – tumbleweed Jun 6 '12 at 17:21

If you're behind a proxy, then you must set the http_proxy enviroment variable in bash. Best way to do it is to open the root shell with sudo bash.

After this, export http_proxy="http://xxx.yyy.zzz.www:abcd"

Then add the repo.

share|improve this answer

Behind proxy, environment variable http_proxy should be set. This can be done in either of the two ways.

1.Create apt.conf file in /etc/apt directory if not present and add the following line to it. Acquire::http::Proxy "http://user:password@server:port";
2.Simply set the environment variable using the following command from terminal.
export http_proxy=http://user:password@server:port

Finally a small tweak, add -E option to the command for the environment variables to be used as follows
sudo -E apt-key adv --keyserver hkp:// --recv-keys 58B98E87

share|improve this answer

I have spent almost two days for this to install the latest version of Mongo DB. But I was facing the same issue as shown below,

$ apt-key adv --keyserver --recv 7F0CEB10

Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.pvb8fwe4Rs --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d//nsa-keyring.gpg --keyserver --recv 7F0CEB10
gpg: requesting key 7F0CEB10 from hkp server
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error

At last I installed mongo DB with the help of steps shared by "ellore".

  1. Added http and https proxy in apt.conf file.
  2. Added the env variables using export http and https command.
  3. Added "-E" in the command line sudo -E apt-key adv --keyserver --recv 7F0CEB10

Then I got the below response,

gpg: requesting key 7F0CEB10 from hkp server
gpg: key 7F0CEB10: "Richard Kreuter <>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1

And I have successfully installed Mongo DB 3.0.7 as shown below,

$ mongo --version
MongoDB shell version: 3.0.7
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.