Ubuntu – How to use “apt-get” via “Http-proxy” like this

aptauthenticationinternetPROXYsynaptic

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: username@urmia.ac.ir

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!

Best Answer

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:password@proxy.server: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:password@10.114.7.7:80";

If you're required to use the @ symbol in your username, you'll have to escape it with a backslash (username@urmia.ac.ir)

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@pass@server.com:port becomes username:my%40pass@server.com:port. See this list of URL-encoded characters for more information.

Related Question