how to install packages with apt-get on a system connected via proxy?

269,704

Solution 1

This method worked for me.....just have a try...

check the file /etc/apt/apt.conf

The contents were,

Acquire::http::proxy "http://<proxy>:<port>/";
Acquire::ftp::proxy "ftp://<proxy>:<port>/";
Acquire::https::proxy "https://<proxy>:<port>/";

This was the reason why you could reach proxy but couldn't get past it, since there is no username password information. So just put that info into it..

Acquire::http::proxy "http://<username>:<password>@<proxy>:<port>/";
Acquire::ftp::proxy "ftp://<username>:<password>@<proxy>:<port>/";
Acquire::https::proxy "https://<username>:<password>@<proxy>:<port>/";

save the file and you are done...


BROTIP: More better add these lines in another file, /etc/apt/apt.conf.d/80proxy. This will ensure that after a version upgrade changes won't be lost.

Solution 2

To configure a proxy temporary, set the http_proxy environment variable. If the proxy is proxy.example.com on port 8080 and you need to authenticate with username user and password pass, run:

sudo http_proxy='http://user:[email protected]:8080/' apt-get install package-name

To set such a proxy permanently, create /etc/apt/apt.conf.d/30proxy containing:

Acquire::http::Proxy "http://user:[email protected]:8080/";

The changes are immediately visible the next time you run apt.

Solution 3

An alternative is to use Synaptics Package Manager, setting in its Preferences the proxy to which you want to connect. You can find the configuration using this path: Settings -> Preferences -> Network

Share:
269,704

Related videos on Youtube

719016
Author by

719016

Updated on September 18, 2022

Comments

  • 719016
    719016 over 1 year

    I've got an Ubuntu 11.10 system connected via a proxy to the internet, and I would like to install packages via apt-get. When I try to do that I get this error message:

    sudo apt-get install libboost-program-options-dev
    [...]
    Err http://gb.archive.ubuntu.com/ubuntu/ oneiric/main libboost1.46-dev i386 1.46.1-5ubuntu2
    407  Proxy Authentication Required
    

    Any ideas?

  • 719016
    719016 over 12 years
    It's still not working, same error. I should mention I have my proxy set up globally on Applications -> System Tools -> System Settings -> Network Proxy -> Apply system Wide
  • Lekensteyn
    Lekensteyn over 12 years
    The proxy connection works for me (tested with netcat as well as Squid). What proxy server is in use? Some proxies may need other authentication methods.
  • wim
    wim over 11 years
    +1 temporary workaround was a more suitable answer for me!
  • jgomo3
    jgomo3 over 10 years
    @Lekensteyn : why did you choose the '30' prefix? i now it define the order of parsing, but: is there a convention about 30 for proxy?
  • Lekensteyn
    Lekensteyn over 10 years
    @jgomo3 I probably looked at the other files (or a README in that directory if it exists?) and then picked a value at random. The files are read in alphabetical order.
  • Vineet Menon
    Vineet Menon over 10 years
    @Hunger, refer this cyberciti.biz/faq/….
  • ldgorman
    ldgorman about 10 years
    if you doing this in the morning, don't forget to delete the chevrons
  • Behrang
    Behrang almost 10 years
    What's the difference between having proxy config in /etc/apt/apt.conf vs /etc/apt/apt.conf.d/30proxy.
  • Lekensteyn
    Lekensteyn almost 10 years
    @Behrang Both are treated by APT as the same thing, but having a separate config file for its purpose makes it easier to disable/enable it.
  • LF00
    LF00 over 7 years
    Acquire::socks::proxy "socks5://server:port";