Laptop Build: apt-get behind a proxy

We have a Netcache webproxy in use at work and so to get the various apt-get and adept commands to work it is necesary to do some configuration.

There are a few posts on the web about how to do this some, saying you just need to set the environment variable http_proxy, others that you must specify the proxy settings in the file /etc/apt/apt.conf.d/70debconf . For my Kubuntu install I found a mixture of the two was required, more of which anon.

Firstly a word about what the url for your proxy should be: If it is a proxy that requires authentication then it will need to be of the form http://username:password@proxy.blah.com:8080” using your username, password and the dns name or ip address of the proxy itself and whatever port number your proxy listens on at the end.

N.B. If your password ever expires and/or gets changed then you will need to update the proxy url wherever you set it.

Following is a summary of my findings and what needs to be set where.

  • Adding a line
    export http_proxy=”http://username:password@proxy.blah.com”

    in /etc/bash.bashrc works fine for using apt-get commands from the command line but the graphical tool adept does not appear to read this file or somehow ignores the http_proxy environment variable.
  • For adept to work you must remove the line Acquire::http::proxy “false”; from /etc/apt/apt.conf to get any other apt.conf.d file settings to work.
  • Add in the line
    Acquire::http::proxy “http://username:password@proxy.blah.com:8080”;

    to the end of /etc/apt/apt.conf.d/70debconf (this file seems to be the “traditional place” to put this setting.)

This got me up and running. I also found the command apt-config dump very useful for displaying the settings that apt-get is going to use. Bear in mind however that for command line apt-get usage the http_proxy environment variable, if it is set, appears to overule whatever Acquire::http::proxy settings you may have in apt.conf.d files.

You can just set the Acquire::http::proxy setting and apt-get from the command line will use this in the same way as adept does but as I like to use wget for fetching the odd file from the ‘net I needed http_proxy set anyway.

Clear as mud? That’s got that sorted then.

Advertisements

8 thoughts on “Laptop Build: apt-get behind a proxy

  1. Been trying to sort this all day, came across this page and had it sorted in minutes. Very useful.

  2. Thanks a ton for posting this. I had the same problem, and following these instructions fixed it. Thanks!!!

  3. WOWWWWWWWWWWWWWWW
    Thankss a lottttt maaaaaannnnnnnnn
    but for me the correct syntax was like this:
    Acquire::http::proxy {“http://user:pass@proxy:port″;};

    With {}

  4. just sample
    Acquire::http::Proxy “http://192.168.30.1:8080”;
    192.168.30.1 = my gateway proxy
    it’s work ^_^

  5. This post seems to attract a lot of spam for some reason and so as it is now over 6 years old I have closed it to further comments.

Comments are closed.