28

I'm trying to use apt-get command on a network that uses a proxy, like this:

We use 10.114.7.7 on port 80 as Http-proxy, and after that an authentication window comes up, asking for user name and password.

Our Username/Domain is like this: [email protected]

I'm wondering, how i can use http_proxy=http://User:Pass@Proxyserver:Port in this situation!? I also tried both, 10.114.7.7 and urmia.ac.ir as Proxy server but no result!

3 Answers 3

41

To use apt-get through a proxy, either make a file in /etc/apt/apt.conf.d/ called proxy or something that you'll recognise, or make (if it doesn't exist) /etc/apt/apt.conf and insert the following line:

Acquire::http::Proxy "http://username:[email protected]:port/";

Simply replace username and password with your login details, and replace proxy.server:port with the correct address (in your case, 10.114.7.7:80), so your line will end up something like this:

Acquire::http::Proxy "http://username:[email protected]:80";

If you're required to use the @ symbol in your username, you'll have to escape it with a backslash ([email protected])

While escaping characters by using the backlash does not work (e.g. \@ in export and wget), special characters can be escaped with URL encoding. For instance, username:my@[email protected]:port becomes username:my%[email protected]:port. See this list of URL-encoded characters for more information.

2
  • 1
    The proposed solution for adding a proxy entry inside /etc/apt worked for me, but I note that if your proxy server caches credentials, you can avoid embedding your credentials in the configuration file by simply authenticating through your proxy server in a different process (e.g. web browser in Windows), prior to running the apt commands in your bash shell. By doing this I was able to specify the proxy entry inside /etc/apt as "server:port" instead of "username:password@server:port". Sep 25, 2019 at 21:04
  • P.S. Don't forget that semicolon ; (not to be as silly as me)
    – ch271828n
    Mar 12, 2020 at 7:12
8

This should solve your problem:

export http_proxy=http://username:[email protected]:80/
4
  • EXPORT HTTP_proxy=http://username:[email protected]:80/ run in Bash results in EXPORT: command not found. May 18, 2015 at 9:36
  • 1
    Both export and http in lower case. Bash is case-sensitive. Else it should work. At least it has been working for me for two years.
    – s3lph
    May 18, 2015 at 11:42
  • 9
    works for curl, but not for apt.
    – FGM
    Jul 27, 2016 at 13:17
  • 2
    For me it worked for apt-get like this. Note tho, it needs to be "http_proxy" not "HTTP_PROXY". Some programs accept both, apt-get seems to only accept the former.
    – Moritz
    Mar 5, 2020 at 15:13
7

Alternatively, you can place the following in /etc/apt/apt.conf

Acquire::http::Proxy "http://proxy.server.port:8080";

8080 is the port number and I think is standard.

Don't forget the quotes or the trailing semicolon.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .