在 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]'
我错过了什么?
最佳答案
创建一个新的空conf文件:$ sudo vi/etc/apt/apt.conf
如果您使用 http 代理,则将此行添加到文件中,否则使用 ftp 的 https:
获取::http::Proxy "http://user:pass@proxy_host:port";
如果您没有代理的用户名和密码,请写入:
获取::http::Proxy "http://proxy_host:port";
注意:不要错过行尾的分号。
关于proxy - Ubuntu 16.04 apt-get 无法通过代理工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38591415/