添加 ppa 存储库时出错:keyserver.ubuntu.com:未找到主机

添加 ppa 存储库时出错:keyserver.ubuntu.com:未找到主机

我今天必须重新安装 Ubuntu,尽管已经为 Apt 配置了代理,但是当尝试添加新的 PPA 时,与之通信的步骤keyserver.ubuntu.com失败:

$ sudo add-apt-repository ppa:webupd8team/sublime-text-3
 Sublime Text 3 Installer: the package in this PPA downloads and installs the latest Sublime Text 3 beta builds.

For more info, see: http://www.webupd8.org/2013/07/sublime-text-3-ubuntu-ppa-now-available.html
 More info: https://launchpad.net/~webupd8team/+archive/ubuntu/sublime-text-3
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmp_wo9o6sl/secring.gpg' created
gpg: keyring `/tmp/tmp_wo9o6sl/pubring.gpg' created
gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
?: keyserver.ubuntu.com: Host not found
gpgkeys: HTTP fetch error 7: couldn't connect: Success
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

我通过 Apt 安装包没有任何问题,所以据我所知,代理设置正确:

$ cat /etc/apt/apt.conf
Acquire::http::proxy "http://my-proxy:8080/";
Acquire::ftp::proxy "ftp://my-proxy:8080/";
Acquire::https::proxy "https://my-proxy:8080/";
Acquire::socks::proxy "socks://my-proxy:8080/";

$ env | grep proxy
http_proxy=http://my-proxy:8080/
ftp_proxy=ftp://my-proxy:8080/
https_proxy=http://my-proxy:8080/

keyserver.ubuntu.com我也可以与以下人员沟通:

$ curl keyserver.ubuntu.com

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>SKS OpenPGP Public Key Server</title>
  </head>
  ...

我不记得过去做过什么不同的事情。我只需要配置http/s_proxy环境变量以及配置/etc/apt/apt.conf

有什么想法我在这里遗漏了什么吗?

答案1

呃!为了验证代理设置是否正确sudo,我进入了交互模式:

$ sudo -i
$ env | grep proxy
https_proxy=http://my-proxy:8080

事实证明,只https_proxy为 root 设置了 。由于我已在 中设置了代理环境变量,因此/etc/environment这有点奇怪,应该sudo为 源/etc/environment

然后我偶然发现#1301557. 14.04.1 是 LTS 版本,虽然早在 2014-04-02 就已报告此错误,但至今尚未修复,这有点令人失望。

为了修复此问题,应将和http_proxyhttps_proxy添加到env_keepsudoers

Defaults        env_keep +="http_proxy"
Defaults        env_keep +="https_proxy"

这解决了问题。

相关内容