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.

In my office i want to update and download through (wget) and here they are using proxy?

How can i do this by commandline?

share|improve this question

7 Answers 7

In some releases sudo is configured in such a way that all environment variables all cleared when running the command. To keep the value for your http_proxy and fix this, you need to edit /etc/sudoers, run:

visudo

Then find a line that states:

Defaults env_reset 

and add after it:

Defaults env_keep = "http_proxy ftp_proxy" 

Things will start working as expected.

Thanks to kdogksu in the Ubuntu Forums for finding the solution for this.

share|improve this answer
1  
Would it be necessary to add "https_proxy" too? –  TenLeftFingers Jan 20 at 9:12
export http_proxy=http://proxyusername:proxypassword@proxyaddress:proxyport
sudo apt-get update

The export shouldn't need sudoing and if your proxy is anonymous, just ditch the proxyusername:proxypassword@ part.

share|improve this answer
    
:-( , I am getting error "Access to web proxy service denied!" –  Renjith G Oct 15 '10 at 11:30
    
Do the same proxy settings work for something simple like wget? –  Oli Oct 15 '10 at 11:41
    
yes ..the same error repeating... –  Renjith G Oct 15 '10 at 11:42
2  
What about editing /etc/apt/apt.conf with Acquire::http::Proxy "MYDOMAIN\MYNAME:[email protected]:MYPORT" ? –  Renjith G Oct 15 '10 at 11:43
    
You can also add this to your ~/.bashrc. Horrible security risk though. –  Scaine Dec 29 '10 at 20:14

Use this.

ubuntu@ubuntu:~$ cat /etc/apt/apt.conf
Acquire::http::Proxy "http://Username:[email protected]:8080";

This is what I use. Works perfectly.

share|improve this answer
1  
I recommend editing this to explain how to add that line to the configuration file. Attempting to run those lines on the command-line won't do it. Right now this answer is based on a correct idea but won't be helpful to a novice. It's not even entirely clear that you're saying that line should be added to apt.conf. –  Eliah Kagan Mar 18 '13 at 4:57

Ubuntu is incredibly hostile to authenticating proxies. I use an Ubuntu laptop at work and the number of breakages is incredible.

Synaptic, Apt, Firefox, Chromium, etc all use different methods for specifying a proxy and there's nowhere to specify credentials securely.

Some bugs on the subject : https://bugs.edge.launchpad.net/ubuntu/+source/msttcorefonts/+bug/220070

https://bugs.edge.launchpad.net/ubuntu/+source/apt-cacher/+bug/198138

https://bugs.edge.launchpad.net/ubuntu/+source/apt/+bug/433827

https://bugs.edge.launchpad.net/ubuntu/+source/b43-fwcutter/+bug/683630

Oli's suggestion to use an export is the only vaguely secure way to do it. It's also sometimes possible to "fudge" proxy support if the proxy server is using secondary authentication to minimise load on the main authentication servers (say perhaps Active Directory). This is where the first proxy connection is authenticated by the proxy against AD, then for a set time period (usually 5 minutes) all other connections are "trusted" to be that user. Therefore, you can open firefox, browse the internet (anywhere will do), then try your utility (wget, synaptic, whatever) by specifying a proxy, but leave the username blank.

Ubuntu is generally hostile to any corporate environment simply because it allows passwords to be read so easily. Seahorse is a prime culprit, but Network Manager is also shocking - connect to any PEAP authenticated network and you've just stored your password in the applet for anyone to see who might borrow your laptop. Apparently laptop sharing is considered sacrilege in Linux land, since Seahorse developers rejected claims of insecurity. After that, I didn't have the heart to contact the network-manager devs.

share|improve this answer
    
I recommend cntlm as a cure for this. It handles authenticating with AD and you set all of your proxy settings to use 127.0.0.1 without requiring any credentials. –  laz Feb 19 at 16:21

If it is a temporary configuration, you could try this: sudo bash -c 'http_proxy="http://< proxy_host >:< proxy_port >/" apt-get update'

You need this, because the environment variable needs to be defined for the "root" account. Doing and export before should not work.

For a permanent configuration, you will have to modify a system file. This is already described in the following answer about How to check Network proxy is really applied?.

share|improve this answer
    
:-( , I am getting error "Access to web proxy service denied!" –  Renjith G Oct 15 '10 at 11:27
    
You probably have to enter a login and password, do you? If so http_proxy should have the form "http://< user >:< pass >@< host >:< port >/" –  Huygens Oct 15 '10 at 13:14

The thing that worked for me was:

sudo http_proxy=http://yourserver apt-get update

Which is a bit odd because simply exporting http_proxy and then running sudo echo $http_proxy obediently printed out the exported value

share|improve this answer

Did you try editing /etc/apt/apt.conf? I use this to use apt behind our corporate proxy.

Acquire::http::proxy "http://user:password@host:port/";

I believe that apt uses this value unless $http_proxy is defined in your shell environment (i.e. $http_proxy takes precedence).

share|improve this answer
    
I'm not sure apt.conf is still in use... When I updated from 8.04 to 10.04 I ended up with impossible update, until I got rid of the proxy settings in that file - then the proxy settings set in Synaptic started to work again... –  Little Jawa Oct 17 '10 at 6:47
    
That's odd - I use apt.conf with 10.04. I find the settings in this file are separate from those configured in the Synaptic package manager preferences gui. –  Jon Brett Oct 18 '10 at 12:05
1  
Yes, apt.conf should still be used. You can see what configuration settings apt thinks it has set by using apt-config dump. –  Steve Beattie Nov 2 '10 at 16:47

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.