Ubuntu set proxy howto


There are several ways of doing this, and different methods may work for different distro’s and versions of ubuntu.

To start, go to the ubuntu menu, select System->Preferences->Network Proxy
Click on manual proxy configuration
Select – Use the same proxy for all protocols
Enter the http proxy
Click on the Details button and enter your proxy username and password

We aint done yet,
1. Open the terminal
Applications->Accessories->Terminal
2. Change to user root by typing
sudo -s
give it your password (one used for logging in)
3. Type
gedit /etc/apt/apt.conf
You will find code similar to
Acquire::http::proxy “http://cache.abc.ac.ma:8080/”;
Acquire::ftp::proxy “ftp://cache.abc.ac.ma:8080/”;
Acquire::https::proxy “https://cache.abc.ac.ma:8080/”;
4. Modify the code to include the authentication(username and password) details for the proxy
Acquire::http::proxy “http://username:password@cache.abc.ac.ma:8080/”;
Acquire::ftp::proxy “ftp://username:password@cache.abc.ac.ma:8080/”;
Acquire::https::proxy “https://username:password@cache.abc.ac.ma:8080/”;

wget Behind proxy

You need to edit the file wgetrc as root:

sudo gedit /etc/wgetrc

Edit the following accordingly and remove the # sign to uncomment the proxy variables:

# You can set the default proxies for Wget to use for http, https, and ftp.
# They will override the value in the environment.
#https_proxy = http://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/

# If you do not want to use proxy at all, set this to off.
#use_proxy = on

Other ways of setting the proxy

You may type this on the terminal when logged in as root:
export http_proxy=”username.password@proxy.bids.ab.ca:portNumber”

or

Still on the terminal, and when logged in as root, edit the file /etc/bash.bashrsc by typing

sudo gedit /etc/bash.bashrc

Once it opens, add at the bottom of the file these 2 lines :

#proxy
export http_proxy=http://user:password@proxy.bids.ab.ca:portNumber/
export ftp_proxy=http://user:pass@proxy.bids.ab.ca:portNumber/
Sources: http://www.unixmen.com/linux-tutorials/939-configure-apt-get-to-work-behind-a-proxy-in-ubuntu-lucid-

  1. Aubrey
    July 2, 2012 at 6:21 PM

    Thanks! gedit /etc/apt/apt.conf worked!

  2. d
    August 15, 2012 at 2:48 AM

    Thanks, this really helps with Ubuntu 12. They screwed that version up.

  3. Hachesse
    January 1, 2014 at 10:04 PM

    Somewhere else i read that /etc/profile could also be modified with the export http_proxy command. That’s what I did and it worked, however the day I no longer needed it, I DID struggle to remove it, since I had no memory where I had made the change – it does not seem to be the most common place to adjust this. So be careful where you doe the export, as you may be in trouble removing it later…

  4. Flavio Becker
    February 14, 2014 at 8:28 PM

    Well, it just doesn’t work when the proxy is a Microsoft TMG or ISA. In those cases the better approach is to install a local proxy like CNTLM as linux cannot auth using ntlmv2 by default. CNTLM intermediates the auth and everything works fine. One needs only to configure the programs (apt-get, wget, …) to use the local proxy.

  1. No trackbacks yet.

Leave a comment