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.
In order to not only fix apt-get but also graphical X11 utils as e.g synaptic,mintintall, ...) the following line in /etc/sudoers should do the job :
Apt also allows individual settings to be placed in files under /etc/apt/apt.conf.d/, so this has exactly the same effect as the above, but may be easier to maintain if you have other lines in the .conf file:
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.
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:
Then find a line that states:
and add after it:
Things will start working as expected.
Thanks to kdogksu in the Ubuntu Forums for finding the solution for this.
In order to not only fix apt-get but also graphical X11 utils as e.g synaptic,mintintall, ...) the following line in
/etc/sudoers
should do the job :Use this.
This is what I use. Works perfectly.
Apt also allows individual settings to be placed in files under
/etc/apt/apt.conf.d/
, so this has exactly the same effect as the above, but may be easier to maintain if you have other lines in the.conf
file:The thing that worked for me was:
Which is a bit odd because simply exporting http_proxy and then running sudo echo $http_proxy obediently printed out the exported value
The export shouldn't need
sudo
ing and if your proxy is anonymous, just ditch theproxyusername:proxypassword@
part.If you want to run “sudo apt-get update” through proxy in commandline, use below command,
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.
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?.
Did you try editing
/etc/apt/apt.conf
? I use this to use apt behind our corporate proxy.I believe that apt uses this value unless $http_proxy is defined in your shell environment (i.e. $http_proxy takes precedence).