Ubuntu 16.04 apt-get not working through proxy

Rodrigo picture Rodrigo · Jul 26, 2016 · Viewed 43.1k times · Source

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)
http_proxy="http://[webproxy]:[port]/"
https_proxy="https://[webproxy]:[port]/"
ftp_proxy="ftp://[webproxy]:[port]/"
socks_proxy="socks://[webproxy]:[port]/"

/etc/profile
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"

/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]/";

or the same changes in
/etc/apt/apt.conf.d/95proxies

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?

Answer

Mohammed picture Mohammed · Nov 14, 2017

Create a 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.