3

问题

我正在尝试在 Ubuntu 虚拟机上运行 apt-get,但我不断收到连接和超时错误。我不确定是什么导致了它们,因为设置了代理。这是我的系统:

系统配置

HOST: Win 7 Enterprise, SP1 (64-bit OS)
RAM: 8 GB
CPU: Intel i5 2.6GHz
VirtualBox 4.2.12
Ubuntu 64 (ubuntu-12.04.2-server-amd64.iso)

重现问题的步骤

这是工作流程及其产生的错误:

1) 从 GitBash(或任何其他 *nix 命令行)通过 SSH 连接到 Ubuntu VM。注意:<localhost_alias>已在 hosts 文件中配置。

ssh -l<username> -p<ftp_port> <localhost_alias>

2)设置你的代理。我只是将这些从文本文件复制粘贴到命令行,然后按回车键来处理最后一个。

export http_proxy=http://proxy.somecorpdom:8080/
export https_proxy=https://proxy.somecorpdom:8080/
export no_proxy=localhost,127.0.0.1,*.somecorpdom

3) 运行 apt-get 更新。

sudo apt-get update

结果和错误

运行更新命令后,立即显示以下内容,但会挂起几分钟:

0% [Connecting to us.archive.ubuntu.com (91.189.91.15)] [Connecting to security.ubuntu.com (91.189.92.202)]

最终,前一条消息消失了,我得到了这个(未删节):

Ign http://us.archive.ubuntu.com precise InRelease
Ign http://us.archive.ubuntu.com precise-updates InRelease
Ign http://us.archive.ubuntu.com precise-backports InRelease
Err http://us.archive.ubuntu.com precise Release.gpg
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates Release.gpg
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports Release.gpg
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Ign http://us.archive.ubuntu.com precise Release
Ign http://us.archive.ubuntu.com precise-updates Release
Ign http://us.archive.ubuntu.com precise-backports Release
Ign http://us.archive.ubuntu.com precise/main TranslationIndex
Ign http://us.archive.ubuntu.com precise/multiverse TranslationIndex
Ign http://us.archive.ubuntu.com precise/restricted TranslationIndex
Ign http://us.archive.ubuntu.com precise/universe TranslationIndex
Ign http://us.archive.ubuntu.com precise-updates/main TranslationIndex
Ign http://us.archive.ubuntu.com precise-updates/multiverse TranslationIndex
Ign http://us.archive.ubuntu.com precise-updates/restricted TranslationIndex
Ign http://us.archive.ubuntu.com precise-updates/universe TranslationIndex
Ign http://us.archive.ubuntu.com precise-backports/main TranslationIndex
Ign http://us.archive.ubuntu.com precise-backports/multiverse TranslationIndex
Ign http://us.archive.ubuntu.com precise-backports/restricted TranslationIndex
Ign http://us.archive.ubuntu.com precise-backports/universe TranslationIndex
23% [Connecting to security.ubuntu.com (91.189.91.14)]
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/restricted Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/universe Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/multiverse Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/main amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/restricted amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/universe amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/multiverse amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/main i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/restricted i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/universe i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/multiverse i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/main Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/restricted Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/universe Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/multiverse Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/main amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/restricted amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/universe amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/multiverse amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/main i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/restricted i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/universe i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/multiverse i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/main Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/restricted Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/universe Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/multiverse Sources
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/main amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/restricted amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/universe amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/multiverse amd64 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/main i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/restricted i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/universe i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/multiverse i386 Packages
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/main Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/main Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/multiverse Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/multiverse Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/restricted Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/restricted Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/universe Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise/universe Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/main Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/main Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/multiverse Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/multiverse Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/restricted Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/restricted Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/universe Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-updates/universe Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/main Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/main Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/multiverse Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/multiverse Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/restricted Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/restricted Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/universe Translation-en_US
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com precise-backports/universe Translation-en
  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]
23% [Connecting to security.ubuntu.com (91.189.91.14)]

它在“23%”停留了很长一段时间。再过几分钟,将显示此输出:

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/universe/binary-i386/Packages  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/multiverse/binary-i386/Packages  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/main/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/main/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/multiverse/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/multiverse/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/restricted/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/restricted/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/universe/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/universe/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/main/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/main/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/multiverse/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/multiverse/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/restricted/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/restricted/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/universe/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-updates/universe/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/main/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/main/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/multiverse/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/multiverse/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/restricted/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/restricted/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/universe/i18n/Translation-en_US  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/universe/i18n/Translation-en  Unable to connect to us.archive.ubuntu.com:http: [IP: 91.189.91.13 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/main/source/Sources  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/restricted/source/Sources  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/universe/source/Sources  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/multiverse/source/Sources  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/main/binary-amd64/Packages  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/restricted/binary-amd64/Packages  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/universe/binary-amd64/Packages  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/multiverse/binary-amd64/Packages  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/main/binary-i386/Packages  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/restricted/binary-i386/Packages  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/universe/binary-i386/Packages  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/multiverse/binary-i386/Packages  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Translation-en_US  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Translation-en  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/multiverse/i18n/Translation-en_US  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/multiverse/i18n/Translation-en  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/restricted/i18n/Translation-en_US  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/restricted/i18n/Translation-en  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/universe/i18n/Translation-en_US  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/universe/i18n/Translation-en  Unable to connect to security.ubuntu.com:http: [IP: 91.189.92.190 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.

我在公司防火墙/代理后面。

4

2 回答 2

18

我找到了答案。这是修复:

将这两行添加到/etc/apt/apt.confas sudo

Acquire::http::proxy "http://somecorpdom:8080/";
Acquire::https::proxy "https://somecorpdom:8080/";

然后 apt-get 应该在你的 Ubuntu 中工作。(将“somecorpdom”更改为您的代理)

于 2013-06-10T16:39:53.850 回答
3

您可以像以前一样导出代理:

export http_proxy=http://proxy.somecorpdom:8080/

export https_proxy=https://proxy.somecorpdom:8080/

然后尝试sudo -E apt-get update

于 2014-04-04T08:29:54.097 回答