我试图在我的 lubuntu 14.04 中配置代理。由于我想使用用户名和密码进行代理身份验证,因此我选择了 ntlm 并安装了它。现在我可以使用我的代理链接 127.0.0.1:3128。由于它是 lubuntu,我没有像在 ubuntu 机器中那样在系统范围内设置代理的 gui 选项。经过谷歌搜索,我找到了一个解决方案,即在 /etc/environment 中添加代理条目,如下所示:
http_proxy=http://127.0.0.1:3128/
https_proxy=http://127.0.0.1:3128/
ftp_proxy=http://127.0.0.1:3128/
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
HTTP_PROXY=http://127.0.0.1:3128/
HTTPS_PROXY=http://127.0.0.1:3128/
FTP_PROXY=http://127.0.0.1:3128/
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"
并创建一个名为 /etc/apt/apt.conf.d/95proxies 的文件,其中包含以下条目:
Acquire::http::proxy "http://127.0.0.1:3128/";
Acquire::ftp::proxy "ftp://127.0.0.1:3128/";
Acquire::https::proxy "https://127.0.0.1:3128/";
我现在的问题是无法使用 apt-get 命令安装任何包。
root@test014:~# apt-get install htop
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
htop
0 upgraded, 1 newly installed, 0 to remove and 153 not upgraded.
Need to get 65.3 kB of archives.
After this operation, 203 kB of additional disk space will be used.
Err http://in.archive.ubuntu.com/ubuntu/ utopic/universe htop amd64 1.0.3-1
407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/universe/h/htop/htop_1.0.3-1_amd64.deb 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
当我以用户身份检查时,我可以看到在环境变量中设置的代理条目:
user1@test014:~$ echo $http_proxy
http://127.0.0.1:3128/
但 root 用户没有显示任何内容:
user1@test014:~$ sudo bash
root@test014:~# echo $http_proxy
root@test014:~# exit
因此,我也在 /etc/bash.bashrc 中添加了相同的代理条目,现在我可以从 root 看到环境变量,但我仍然无法以 root 或使用 sudo 的普通用户身份运行 apt-get 命令。请指教
答案1
据我所知,您的代理服务器需要身份验证:
407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/universe/h/htop/htop_1.0.3-1_amd64.deb 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )
因此您必须使用另一个代理设置语法:
http_proxy="http://username:password@proxyserver:port"
https_proxy="http://username:password@proxyserver:port"
...
这些用户名和密码是网络管理员通常提供的代理服务器参数(在我们的网络中它们是用户名@域:密码)