ubuntu中的系统范围代理设置
我想在我的大学代理服务器上使用互联网,这也需要身份validation。 我搜索谷歌的解决方案,我发现的最佳解决方案是这个 。 我已在接受的答案中修改了脚本以包含身份validation。 它来了:
if [ $(id -u) -ne 0 ]; then echo "This script must be run as root"; exit 1; fi if [ $# -eq 4 ] then gsettings set org.gnome.system.proxy mode 'manual' ; gsettings set org.gnome.system.proxy.http host '$1'; gsettings set org.gnome.system.proxy.http port $2; gsettings set org.gnome.system.proxy.http authentication-user '$3'; gsettings set org.gnome.system.proxy.http authentication-password '$4'; grep PATH /etc/environment > lol.t; printf \ "http_proxy=http://$3:$4@$1:$2/\n\ https_proxy=http://$3:$4@$1:$2/\n\ ftp_proxy=http://$3:$4@$1:$2/\n\ no_proxy=\"localhost,127.0.0.1,localaddress,.localdomain.com\"\n\ HTTP_PROXY=http://$3:$4@$1:$2/\n\ HTTPS_PROXY=http://$3:$4@$1:$2/\n\ FTP_PROXY=http://$3:$4@$1:$2/\n\ NO_PROXY=\"localhost,127.0.0.1,localaddress,.localdomain.com\"\n" >> lol.t; cat lol.t > /etc/environment; printf \ "Acquire::http::proxy \"http://$3:$4@$1:$2/\";\n\ Acquire::ftp::proxy \"ftp://$3:$4@$1:$2/\";\n\ Acquire::https::proxy \"https://$3:$4@$1:$2/\";\n" > /etc/apt/apt.conf.d/95proxies; rm -rf lol.t; else printf "Usage $0 \n"; fi
但是, 在线帐户仍然不起作用(对于rhythmbox和其他GTK3程序也是如此) 。 白色屏幕显示如下:
有关如何解决的任何建议?
终于解决了:
(按顺序执行步骤)
1.对于gtk3程序,如rhythmbox和在线账户:
首先,您需要在网络设置中输入代理设置(以及身份validation):
然后应用系统范围。
2.适用于apt,软件中心等
编辑文件/etc/apt/apt.conf
然后通过以下行替换所有现有文本
Acquire::http::proxy "http://username:password@host:port/"; Acquire::ftp::proxy "ftp://username:password@host:port/"; Acquire::https::proxy "https://username:password@host:port/";
3.环境变量
编辑文件/etc/environment
然后在PATH =“这里的东西”之后添加以下行
http_proxy=http://username:password@host:port/ ftp_proxy=ftp://username:password@host:port/ https_proxy=https://username:password@host:port/
就这样..
要通过wget代理下载软件包必须在/ etc / environment中设置,并且必须在/etc/apt/apt.conf中设置apt-get代理下载软件包
当然,这不是全部。 一些更多的程序( npm
, curl
和git
):
npm config set proxy $HTTP_PROXY npm config set https-proxy $HTTPS_PROXY npm config set strict-ssl false echo "proxy = $HTTP_PROXY" > ~/.curlrc echo "noproxy = $NO_PROXY" >> ~/.curlrc git config --global http.proxy $HTTP_PROXY git config --global https.proxy $HTTPS_PROXY
对于Maven,编辑~/.m2/settings.xml
。 IntelliJ似乎也没有拿起全局配置。
为了让wget
与代理一起工作,我还要添加在你的主目录中创建一个.wgetrc
,其中包含:
http_proxy = http://proxy:port/ https_proxy = http://proxy:port/ proxy_user = user proxy_password = password use_proxy = on wait = 15