ubuntu 中的系统范围代理设置

Ram*_*man 22 proxy 14.04

我想在我的大学代理服务器上使用互联网,这也需要身份验证。我在谷歌上搜索了解决方案,我找到的最好的解决方案是这个。我已经修改了接受的答案中的脚本以包含身份验证。它是这样的:

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 <proxy_ip> <proxy_port> <username> <password>\n";

fi
Run Code Online (Sandbox Code Playgroud)

但是在线帐户仍然不起作用(对于 rhythmbox 和其他 GTK3 程序也是如此)。白屏显示如下:

在此处输入图片说明

有关如何解决的任何建议?

Ram*_*man 33

终于解决了:

(按顺序依次执行)

1、对于rhythmbox、在线账号等gtk3程序:

首先,您需要在网络设置中输入代理设置(以及身份验证):

在此处输入图片说明

然后在系统范围内应用。

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/";
Run Code Online (Sandbox Code Playgroud)

3. 环境变量

编辑文件 /etc/environment

然后在 PATH="something here" 后面添加以下几行

http_proxy=http://username:password@host:port/
ftp_proxy=ftp://username:password@host:port/
https_proxy=https://username:password@host:port/
Run Code Online (Sandbox Code Playgroud)

就这样..