Ubuntu 16.04 apt-get无法通过代理工作

问题描述 投票:7回答:3

在Ubuntu 14.04中,为了通过公司代理在终端中使用某些命令(如apt-get),我需要做以下更改,除了系统设置>网络>网络代理>“应用系统范围”(遗憾的是,您,Ubuntu)

/etc/environment (actually this is the only file modified by System Settings)
http_proxy="http://[webproxy]:[port]/"
https_proxy="https://[webproxy]:[port]/"
ftp_proxy="ftp://[webproxy]:[port]/"
socks_proxy="socks://[webproxy]:[port]/"

/etc/profile
export http_proxy=http://[username]:[password]@[webproxy]:[port]
export https_proxy=http://[username]:[password]@[webproxy]:[port]
export ftp_proxy=http://[username]:[password]@[webproxy]:[port]

sudo visudo
Defaults        env_reset
Defaults        env_keep = "http_proxy https_proxy ftp_proxy DISPLAY XAUTHORITY"

/etc/apt/apt.conf
Acquire::http::proxy "http://[username]:[password]@[webproxy]:[port]/";
Acquire::https::proxy "https://[username]:[password]@[webproxy]:[port]/";
Acquire::ftp::proxy "ftp://[username]:[password]@[webproxy]:[port]/";
Acquire::socks::proxy "socks://[username]:[password]@[webproxy]:[port]/";

or the same changes in
/etc/apt/apt.conf.d/95proxies

我认为至少以下命令(来自here

sudo http_proxy='http://[username]:[password]@[webproxy]:[port]' apt-get update

应该工作,对吧?

这就是我现在记得的。甚至不确定是否所有这些都是真的必要。我在Ubuntu 16.04中进行了所有这些更改,但是仍然无法使sudo apt-get update通过同一代理(同一房间中的另一台计算机)工作。获得

Temporary failure resolving '[webproxy]'

我想念什么?

proxy apt-get ubuntu-16.04
3个回答
13
投票

创建一个新的空conf文件:$ sudo vi /etc/apt/apt.conf

如果您使用的是HTTP代理,则将这一行添加到文件,否则使用FTP的https:Acquire::http::Proxy "http://user:pass@proxy_host:port";

如果您没有代理的用户名和密码,请输入:Acquire::http::Proxy "http://proxy_host:port";注意:不要错过行尾的分号。


1
投票

我遇到了同样的问题,并按照以下解决方案进行了修复:https://www.unixmen.com/45713-2/from M.el Khamlichi

  1. 在/ etc / apt /中创建文件apt.conf。

    sudo vi /etc/apt/apt.conf
    
  2. 在其中添加代理

  3. export http_proxy=http://192.168.168.180:3128 
    

    [这里您要输入数字。

  4. 将其添加到〜/ .bash.rc中,使该命令永久生效

  5. vi ~/.bash.rc
    

1
投票

在Ubuntu桌面上唯一对我有用的是

© www.soinside.com 2019 - 2024. All rights reserved.