Linux: Apt Proxy Add/Remove


check /etc/apt/apt.conf

add/ remove Aquire::<protocol> as needed

  • /etc/apt/apt.conf
  • Acquire::http::proxy "http://[username]:[password]@[webproxy]:[port]/";
  • Acquire::https::proxy "https://[username]:[password]@[webproxy]:[port]/";
  • Acquire::ftp::proxy "ftp://[username]:[password]@[webproxy]:[port]/";
  • Acquire::socks::proxy "socks://[username]:[password]@[webproxy]:[port]/";

In Ubuntu 14.04, in order to use some commands in terminal (like apt-get) trough the company proxy, I need to do the following changes, beyond System Settings > Network > Network proxy > "Apply system wide" (shame on you, Ubuntu)

/etc/environment (actually this is the only file modified by System Settings)

export http_proxy=http://[username]:[password]@[webproxy]:[port]
export https_proxy=http://[username]:[password]@[webproxy]:[port]
export ftp_proxy=http://[username]:[password]@[webproxy]:[port]

sudo visudo
Defaults        env_reset
Defaults        env_keep = "http_proxy https_proxy ftp_proxy DISPLAY XAUTHORITY"

Acquire::http::proxy "http://[username]:[password]@[webproxy]:[port]/";
Acquire::https::proxy "https://[username]:[password]@[webproxy]:[port]/";
Acquire::ftp::proxy "ftp://[username]:[password]@[webproxy]:[port]/";
Acquire::socks::proxy "socks://[username]:[password]@[webproxy]:[port]/";

or the same changes in

I think that at least the following command (from here)

sudo http_proxy='http://[username]:[password]@[webproxy]:[port]' apt-get update

should work, right?

That's what I remember right now. Not even sure if all of them are really necessary. I did all these changes in Ubuntu 16.04, though, but still can't make sudo apt-get update work through the same proxy (another computer in the same room). Got

Temporary failure resolving '[webproxy]'

What am I missing?




Create new empty conf file: $ sudo vi /etc/apt/apt.conf

Add this line to the file if you are using http proxy else https of ftp:
Acquire::http::Proxy "http://user:pass@proxy_host:port";

If you don't have a usename and password for your proxy then write:
Acquire::http::Proxy "http://proxy_host:port";
Note: don't miss the semicolon at the end of line.

I had the same problem and I fix it following this solution: from M.el Khamlichi

  1. create a file apt.conf in /etc/apt/

    sudo vi /etc/apt/apt.conf
  2. add there the proxy

    export http_proxy= 

    Here you wil put your numbers.

  3. add it to ~/.bash.rc to make this command permanent

    vi ~/.bash.rc
  • Sorry, not working there anymore. Probably found a workaround at the time. – Rodrigo Dec 25 '16 at 15:41
  • What message are you getting now? Have you change your password ? – Mariano Cali Dec 26 '16 at 17:19
  • What message are you getting now? Have you change your password ? It is possible that you need to update your password in the export proxy command? Have you change some settings in the System Settings about network proxy ? greats. ! – Mariano Cali Dec 26 '16 at 17:23
  • I don't even remember now. And since I don't work there anymore, I can't verify anything. But thanks for your support. – Rodrigo Dec 26 '16 at 21:09
  • I am sorry that you could not work there anymore. I hope that you can configure and use it in another work in the future. – Mariano Cali Dec 28 '16 at 18:48

The only thing that worked for me in Ubuntu Desktop was to

  1. Go to System Settings
  2. Search for "proxy"
  3. Go to Network Settings
  4. Go to Network proxy
  5. Enter HTTP Proxy and HTTP Proxy settings