Answers:
据我了解,通过该GUI在系统范围内设置代理可以完成三件事:
/etc/environment
。/etc/apt/apt.conf
。1和3立即生效。/etc/environment
是在登录时解析的,因此您需要注销并登录才能生效。(请注意,这是正确的登录方式,而不仅仅是运行登录shell。)以下脚本应该等效(假设使用http / https代理):
#! /bin/bash
HTTP_PROXY_HOST=proxy.example.com
HTTP_PROXY_PORT=3128
HTTPS_PROXY_HOST=proxy.example.com
HTTPS_PROXY_PORT=3128
gsettings set org.gnome.system.proxy mode manual
gsettings set org.gnome.system.proxy.http host "$HTTP_PROXY_HOST"
gsettings set org.gnome.system.proxy.http port "$HTTP_PROXY_PORT"
gsettings set org.gnome.system.proxy.https host "$HTTPS_PROXY_HOST"
gsettings set org.gnome.system.proxy.https port "$HTTPS_PROXY_PORT"
sudo sed -i.bak '/http[s]::proxy/Id' /etc/apt/apt.conf
sudo tee -a /etc/apt/apt.conf <<EOF
Acquire::http::proxy "http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT/";
Acquire::https::proxy "http://$HTTPS_PROXY_HOST:$HTTPS_PROXY_PORT/";
EOF
sudo sed -i.bak '/http[s]_proxy/Id' /etc/environment
sudo tee -a /etc/environment <<EOF
http_proxy="http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT/"
https_proxy="http://$HTTPS_PROXY_HOST:$HTTPS_PROXY_PORT/"
EOF
即使需要重新登录才能将PAM应用到任何/etc/environment
地方,在当前Shell中,您仍然可以提取该文件中的值:
export http_proxy=$(pam_getenv http_proxy)
gsettings get org.gnome.system.proxy mode; gsettings get org.gnome.system.proxy.http host; gsettings get org.gnome.system.proxy.http port;
什么?
(process:9662): dconf-WARNING **: failed to commit changes to dconf: Could not connect: Connection refused
,gsettings中的每个命令都会显示警告。如果我以root身份运行,则可以正常运行,但是上述命令(get)的输出仅在root用户中已更改,而在普通用户中未更改。
sudo tee
,请注意文件名/etc/environment
不是/etc/apt/apt.conf
。您可能必须删除apt.conf中的垃圾条目。
我认为这应该避免头痛:
出色的教程,在python中运行。在Ubuntu 12.04 / 12.10 / 13.04 / 13.10 / 14.04 / 14.10及更高版本中设置简单且经过身份验证的代理设置100%正常工作。
解决方案1 系统必须安装为“ python”。在解释器运行命令的情况下:命令:“ sudo python setproxy.py [Proxy_Server] [proxy_port] [PROXY_USER] [proxy_password]”
视频:https://www.youtube.com/watch?v = eBtzKa-dvJg
[ Proxy_Server ] : proxy.test.ts
[ Proxy_port ] : 8080
[ PROXY_USER ] : domainuser
[ Proxy_password ] : " the_password "
解决方案2: 命令:
"Sudo apt- get install python- support"
"Sudo apt- get install ntlmaps "
填写相应的字段:
- Proxy server
- Proxy port
- User
- Password
sudo service network manager restart
。