How to use apt-get/synaptic behind a proxy? [duplicate]

Solution 1:

For my corporate network I was given by my administrator the proxy name in the format:

http://[username]:[password]@[proxy-webaddress]:[port]

For our Windows network our username is in the format:

[domain]\[username]

For example:

http://mywindowsdomain\fossfreedom:[email protected]:8080

This was added to the following NEW file (it doesnt exist by default):

gksudo gedit /etc/apt/apt.conf.d/01proxy

The following text was added:

Acquire::http::Proxy "http://mywindowsdomain\fossfreedom:[email protected]:8080";

If you are using an anonymous proxy then you don't need your login credentials:

Acquire::http::Proxy "http://askubuntu-proxy.com:8080";

Save the file and then checked that all was ok with:

sudo apt-get update

Solution 2:

I have found that USERNAME and PASSWORD entered into the "Network Proxy" applet does not get stored into the apt.conf file you must manually add the username and password in the /etc/apt/apt.conf file.

The "Network Proxy" applet only stores the hostname and the port.

The basic syntax is

Acquire::http::proxy "http://User:Password@host:port/";

Acquire::ftp::proxy "ftp://User:Password@host:port/";

Acquire::https::proxy "https://User:Password@host:port/";

If you are using Windows usernames and password follow this advice:

User = Domain/Username

(windows users use / not \)

If you are using Windows strong/complex password with special characters you must use the URL encoding for the values, for example an "@" in the password would be "%40".

Solution 3:

Try setting http_proxy to http://user:pass@proxyserver:port/

edit:
If setting http_proxy does not work try editing apt.conf. In
Ubuntu apt.conf is fragmented in /etc/apt/apt.conf.d/ directory.
In this directory edit /etc/apt/apt.conf.d/01ubuntu:

APT {
    Acquire {
        http {
            Proxy "http://user:password@server:port";
        };
    };
};

or try setting it using Synaptic: Settings -> Preferences -> Network
And then set your proxy settings in "Manual proxy configuration".

Solution 4:

I'm behind a MS ISA proxy and I'm using Cntlm Authentication Proxy; in the apt.conf I have 4 lines; I've read somewhere that the last line must be empty, but I'm not sure about it. It works perfectly:

Acquire::http::proxy "http://127.0.0.1:3128/";
Acquire::ftp::proxy "ftp://127.0.0.1:3128/";
Acquire::https::proxy "https://127.0.0.1:3128/";