首页 文章

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

提问于
浏览
6

在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

应该工作吧?

's what I remember right now. Not even sure if all of them are really necessary. I did all these changes in Ubuntu 16.04, though, but still can' t使 sudo apt-get update 通过相同的代理(同一房间中的另一台计算机)工作 . 拿到

Temporary failure resolving '[webproxy]'

我错过了什么?

3 回答

  • 0

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

    如果您使用的是http代理,请将此行添加到文件中,否则https为ftp:
    Acquire::http::Proxy "http://user:pass@proxy_host:port";

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

  • 1

    我有同样的问题,我按照这个解决方案修复它:https://www.unixmen.com/45713-2/来自M.el Khamlichi

    • 在/ etc / apt /中创建一个apt.conf文件
    sudo vi /etc/apt/apt.conf
    
    • 在那里添加代理
    export http_proxy=http://192.168.168.180:3128
    

    在这里你会把你的数字 .

    • 将其添加到〜/ .bash.rc以使此命令永久化
    vi ~/.bash.rc
    
  • 10

    在Ubuntu Desktop中唯一对我有用的是

    • 进入系统设置

    • 搜索"proxy"

    • 转到“网络设置”

    • 转到网络代理

    • 输入HTTP代理和HTTP代理设置

相关问题