在 Ubuntu 15.04 中导出代理设置后使用 add-apt-repository 时出现代理身份验证错误

在 Ubuntu 15.04 中导出代理设置后使用 add-apt-repository 时出现代理身份验证错误

我正在尝试导出代理设置后通过终端添加存储库。

export http_proxy="http://username:password@proxy":"port"
export https_proxy="https://username:password@proxy":"port"
sudo -E add-apt-repository ppa:umang/indicator-stickynotes

结果:

Traceback (most recent call last):
File "/usr/lib/python3.4/urllib/request.py", line 1182, in do_open
 h.request(req.get_method(), req.selector, req.data, headers)
File "/usr/lib/python3.4/http/client.py", line 1088, in request
  self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1126, in _send_request
  self.endheaders(body)
File "/usr/lib/python3.4/http/client.py", line 1084, in endheaders
  self._send_output(message_body)
File "/usr/lib/python3.4/http/client.py", line 922, in _send_output
  self.send(msg)
File "/usr/lib/python3.4/http/client.py", line 857, in send
  self.connect()
File "/usr/lib/python3.4/http/client.py", line 1223, in connect
  super().connect()
File "/usr/lib/python3.4/http/client.py", line 837, in connect
  self._tunnel()
File "/usr/lib/python3.4/http/client.py", line 820, in _tunnel
      message.strip()))
OSError: Tunnel connection failed: 407 Proxy Authentication Required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 101, in _get_https_content_py3
  lp_page = urllib.request.urlopen(request, cafile=LAUNCHPAD_PPA_CERT)
File "/usr/lib/python3.4/urllib/request.py", line 161, in urlopen
  return opener.open(url, data, timeout)
File "/usr/lib/python3.4/urllib/request.py", line 463, in open
  response = self._open(req, data)
File "/usr/lib/python3.4/urllib/request.py", line 481, in _open'_open', req)
File "/usr/lib/python3.4/urllib/request.py", line 441, in _call_chain
  result = func(*args)
File "/usr/lib/python3.4/urllib/request.py", line 1225, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.4/urllib/request.py", line 1184, in do_open
 raise URLError(err)
urllib.error.URLError: <urlopen error Tunnel connection failed: 407 Proxy Authentication Required>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 321, in get_ppa_info
  ret = get_ppa_info_from_lp(user, ppa)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 91, in get_ppa_info_from_lp
  return get_info_from_lp(lp_url)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 87, in get_info_from_lp
  return _get_https_content_py3(lp_url)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 107, in _get_https_content_py3
  raise PPAException("Error reading %s: %s" % (lp_url, reason), e)
softwareproperties.ppa.PPAException: 'Error reading https://launchpad.net/api/1.0/~umang/+archive/ubuntu/indicator-stickynotes: Tunnel connection failed: 407 Proxy Authentication Required'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.4/urllib/request.py", line 1182, in do_open
  h.request(req.get_method(), req.selector, req.data, headers)
File "/usr/lib/python3.4/http/client.py", line 1088, in request
  self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1126, in _send_request
  self.endheaders(body)
File "/usr/lib/python3.4/http/client.py", line 1084, in endheaders
  self._send_output(message_body)
File "/usr/lib/python3.4/http/client.py", line 922, in _send_output
  self.send(msg)
File "/usr/lib/python3.4/http/client.py", line 857, in send
  self.connect()
File "/usr/lib/python3.4/http/client.py", line 1223, in connect
  super().connect()
File "/usr/lib/python3.4/http/client.py", line 837, in connect
  self._tunnel()
File "/usr/lib/python3.4/http/client.py", line 820, in _tunnel
  message.strip()))
OSError: Tunnel connection failed: 407 Proxy Authentication Required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 101, in _get_https_content_py3
  lp_page = urllib.request.urlopen(request, cafile=LAUNCHPAD_PPA_CERT)
File "/usr/lib/python3.4/urllib/request.py", line 161, in urlopen
  return opener.open(url, data, timeout)
File "/usr/lib/python3.4/urllib/request.py", line 463, in open
  response = self._open(req, data)
File "/usr/lib/python3.4/urllib/request.py", line 481, in _open '_open', req)
File "/usr/lib/python3.4/urllib/request.py", line 441, in _call_chain
  result = func(*args)
File "/usr/lib/python3.4/urllib/request.py", line 1225, in https_open
  context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.4/urllib/request.py", line 1184, in do_open
  raise URLError(err)
urllib.error.URLError: <urlopen error Tunnel connection failed: 407 Proxy Authentication Required>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 119, in <module>
  shortcut = shortcut_handler(line)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 837, in shortcut_handler
  ret = factory(shortcut)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 382, in shortcut_handler
  return PPAShortcutHandler(shortcut)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 346, in __init__
  info = get_ppa_info(self.shortcut)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 333, in get_ppa_info
  _get_suggested_ppa_message(user, ppa))
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 292, in _get_suggested_ppa_message
  lp_user = get_info_from_lp(LAUNCHPAD_USER_API % user)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 87, in get_info_from_lp
  return _get_https_content_py3(lp_url)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 107, in _get_https_content_py3
  raise PPAException("Error reading %s: %s" % (lp_url, reason), e)
softwareproperties.ppa.PPAException: 'Error reading https://launchpad.net/api/1.0/~umang: Tunnel connection failed: 407 Proxy Authentication Required'

显然,代理身份验证存在一些问题。如何解决?

apt-get、软件中心和 synaptic 等都与我的代理身份验证配合使用。只有这个add-apt-repository命令失败了。

答案1

为什么要拆分端口?试试这个。

export http_proxy="http://username:password@proxy:port/"
export https_proxy="https://username:password@proxy:port/"
sudo -E add-apt-repository ppa:umang/indicator-stickynotes

或者添加/etc/apt/apt.conf以下几行并重新登录:

Acquire::http::proxy "http://username:password@proxy:port/";
Acquire::https::proxy "http://username:password@proxy:port/";
Acquire::ftp::proxy "http://username:password@proxy:port/";
Acquire::socks::proxy "http://username:password@proxy:port/";
Acquire::::Proxy "true";

答案2

试试这个。在运行apt命令之前运行这个。

有时apt会忽略apt.conf;在这种情况下您需要明确导出它:

export http_proxy=<YOUR PROXY>/;
export HTTP_PROXY=<YOUR PROXY>/;
export https_proxy=<YOUR PROXY>/;
export HTTPS_PROXY=<YOUR PROXY>/;

答案3

正确尝试代理 URL 和端口

Acquire::http::proxy "http://<proxy url>:<port>";
Acquire::https::proxy "https://<proxy url>:<port>";
Acquire::ftp::proxy "ftp://<proxy url>:<port>";
Acquire::socks::proxy "socks:<proxy url>:<port>";

例子:

Acquire::http::proxy "http://abc.com.net:8080";
Acquire::https::proxy "https://abc.com.net:8080";
Acquire::ftp::proxy "ftp://abc.com.net:8080";
Acquire::socks::proxy "socks:abc.com.net:8080";

输入与网络代理脚本中提到的完全一致的端口号。

如果你的主机是 Windows 7,而客户机操作系统是 Ubuntu,那么你可以下载网络代理脚本 浏览器 -> Internet 选项 -> 连接 -> LAN 设置 -> 使用自动配置脚本 -> 复制 URL

然后粘贴到浏览器中。现在将下载您的脚本,您可以从该脚本中复制 PROXYURL 和 PORT

并将其/etc/apt/apt.conf 以 root 用户身份粘贴到您的 Ubuntu 客户操作系统中。apt.conf不存在,您必须自己制作。

相关内容