22

I wanted to use internet on my college proxy server which also requires authentication. I searched google for solutions and the best solution I found yet was this . I have modified the script in the accepted answer to include authentication. Here it goes:

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

However Online accounts still don't work(same for rhythmbox and other GTK3 programs). A white screen appears like this:

enter image description here

Any suggestions on how it can be solved?

1
33

Solved it finally:

(Follow the steps serially)

1. For gtk3 programs such as rhythmbox and online accounts:

First you need to enter proxy settings in network settings (along with authentication):

enter image description here

Then apply system wide.

2. For apt,software center etc

edit the file /etc/apt/apt.conf

And then replace all the existing text by the following lines

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. Environment variables

edit the file /etc/environment

And then add the following lines after PATH="something here"

http_proxy=http://username:password@host:port/
ftp_proxy=ftp://username:password@host:port/
https_proxy=https://username:password@host:port/

That's all..

3
  • 1
    Does step 1) alter /etc/environment? I'd like a way to do that step via the command line.
    – Lucas
    Nov 9 '16 at 0:05
  • Seems step 1) works for apt-get update as well. So don't need step 2). May 9 '17 at 3:25
  • @Raman I there any need to escape the special characters in password while doing this? If so then how? Nov 15 '18 at 9:28
2

To download packages by wget proxy have to be setup in /etc/environment, and to download packages by apt-get proxy have to be setup in /etc/apt/apt.conf

2
  • 2
    Please elaborate your answer, it is currently not providing much helpful information.
    – Byte Commander
    Jul 12 '16 at 10:55
  • 1
    Welcome to Ask Ubuntu! I recommend editing this answer to expand it with specific details about how to do this. (See also How do I write a good answer? for general advice about what sorts of answers are considered most valuable on Ask Ubuntu.) Jul 12 '16 at 11:41
2

That’s not all, of course. Some more programs (npm, curl and 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

For Maven, edit ~/.m2/settings.xml. IntelliJ does not seem to pick up the global config either.

1

To make wget work with a proxy, I would add also to create a .wgetrc in your home directory, containing :

http_proxy = http://proxy:port/
https_proxy = http://proxy:port/
proxy_user = user
proxy_password = password
use_proxy = on
wait = 15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.