Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

For the command

sudo apt-get update

I get following error:

W: Failed to fetch http://ch.archive.ubuntu.com/ubuntu/dists/maverick-updates/multiverse/binary-i386/Packages.gz  
407  Proxy Authentication Required (The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )

I am running Ubuntu 10.10 installed on Windows XP using VirtualBox. For Internet connections I am using proxy server with an authentication. I tried to use gnome-network-proxy tool to set proxy settings system-wide.

After that /etc/environment has been updated by http_proxy variable with the format http://my_proxy:port/, there were no authentication data.

I checked this with Firefox. Browser asked my for login and password and everything was working fine. It was unfortunately not the case for apt-get. I have also tried to do as described here. Unfortunately it does not work.

May it be somehow related to the fact that a proxy is in a Windows domain, any ideas?

My proxy name is http-proxy. Is '-' a special character here?

share|improve this question
2  
Have you used the global network proxy under system --> preferences --> network proxy, and applyed the settings globaly? –  DemonWareXT May 3 '11 at 9:49

9 Answers 9

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:password@askubuntu-proxy.com: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:password@askubuntu-proxy.com: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
share|improve this answer
    
To those who will read this later: This seem like a hack to the untrained eye, but it is an incredibly simple way to get the corporate proxy to obey. –  macduff Jun 26 '12 at 19:55
    
This works perfectly. UNLESS you have earlier set the /etc/apt/apt.conf with a bad Acquire line. I did just that, and all I had to do was go back and delete that line. –  Skip Huffman Aug 17 '12 at 13:44
    
On Ubuntu 12.10, I had to copy the changes made to /etc/apt/apt.conf.d/01proxy to /etc/apt/apt.conf before it would work. –  Stephen Niedzielski Mar 26 '13 at 19:18
    
even with these edits I couldn't get this to work for me with 12.04... but I managed to get this to work by using and configuring ntlmaps and pointing the apt.conf file to the intermediate proxy there. –  monkut May 2 '13 at 7:54

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".

share|improve this answer
3  
Do you mean /etc/environment file ? –  tommyk Jan 28 '11 at 12:46
    
Yest, it will set this variable globally. –  Casual Coder Jan 28 '11 at 18:02
    
How would one encode the colon as part of the password? –  k0pernikus Dec 19 '11 at 9:34
    
/etc/environment is not working with apt-get (or at least it requires restart ;), changing apt.conf has immediate effect –  Donaudampfschifffreizeitfahrt May 22 '12 at 13:56
    
I can confirm setting "Manual proxy configuration" and "Apply system wide" in Network works with apt-get. –  Will Sheppard Mar 10 at 14:41

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".

share|improve this answer
    
(windows users use / not ) So THAT's why I'm stuck :) Thanks! –  GaiusSensei May 19 '12 at 5:35

I'm behind MS ISA PROXY and I'm using Cntlm Authentication Proxy soft and 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 perfect:

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/";
share|improve this answer
up vote 3 down vote accepted

cntlm has a discovery option that helps find the right config to work with the NTLM auth of your network, try this:

cntlm -I -M http://test.com

copy and paste the results in /etc/cntlm.conf

restart cntlm

share|improve this answer
  1. Open terminal and add the following lines to /etc/apt/apt.conf.

    gksu gedit /etc/apt/apt.conf
    
  2. Add these 2 lines:

    Acquire::http::Proxy "http://user:pass@proxy-host:port/";
    Acquire::ftp::Proxy "http://user:pass@proxy-host:port/";
    
  3. Save and exit.

    Now apt-get update and should work behind a proxy, but you will notice that still something is not working, that is the add-apt-repository command.

    To be able to add repository behind a proxy, type the following commands:

    # export https_proxy="http://192.168.1.5:8080"
    # sed -i 's/"keyserver.ubuntu.com"/"hkp://keyserver.ubuntu.com:80"/' /usr/share`/pyshared/softwareproperties/ppa.py`
    

    Now you can add repositories in Lucid and Natty using LANG=C add-apt-repository

    Example:

    root@ubuntu:~# LANG=C add-apt-repository ppa:motumedia/mplayer-daily

Via Unixmen

share|improve this answer

With a BlueCoat proxy, for me the format of the apt.conf file was required to look like:

Acquire::http::proxy "http://Domain%5cUserID:Password@proxy.name.whatever:80/";
Acquire::ftp::proxy "ftp://Domain%5cUserID:Password@proxy.name.whatever:80/";
Acquire::https::proxy "https://Domain%5cUserID:Password@proxy.name.whatever:80/";

^ ^ ^ ^ Blank line after 3rd proxy line, do not enter this line. ^ ^ ^ ^

share|improve this answer

How to apply apt-get update or install in Ubuntu ? I was behind a proxy server and after installing Ubuntu i coulden`t update or install anything using the apt-get command. After searching i found that The apt package has been changed, now there is no more apt.conf on /etc/apt directory.

What i did to resolve this issue is the follow :

Open terminal and the file

/etc/bash.bashrsc

sudo gedit /etc/bash.bashrc

and add at the bottom of the file these 2 lines :

#proxy 
export http_proxy=http://user:password@host:port/
export ftp_proxy=http://user:pass@host:port/

Now save and exit, Now you will be able to update, upgrade or install packages in Ubuntu

share|improve this answer
    
I have added exports as you suggested. It still does not work. Now I got a different error message "Could not connect to extras.ubuntu.com:80 (91.189.88.33). - connect (110: Connection timed out)". <br> Strange thing is that when I enter the same proxy settings in Firefox preferences then I can browse a web. –  tommyk Jan 28 '11 at 13:58
    
@tommyk could you post your /etc/apt/sources.list and update your question here or try to delete extras.ubuntu.com from your /etc/apt/sources.list and execute apt-get update –  hhlp Jan 28 '11 at 14:16
    
I've replaced my sources.list with a default one from ubuntu web page. I still got the same error for every repository listed in a this file. –  tommyk Jan 28 '11 at 15:09
  1. Start Synaptic (go to System -> Administration -> Synaptic in Gnome 2, or type "synaptic" in the Dash in Unity).
  2. On the menu bar, click Settings, followed by Preferences.
  3. When the Preferences window appears, click on the Network tab.
  4. Select the Manual proxy configuration radio button and enter your proxy information.
  5. To apply authentication information, click the Authentication button and enter username and password.
  6. Click OK to close the HTTP Authentication window.
  7. Click OK to close the Preferences window.
  8. Click the Reload button to update the package lists.

Note that this setting change will also affect the Update Manager.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.