Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu 16.04 apt-get not working through proxy

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?

like image 993
Rodrigo Avatar asked Jul 26 '16 13:07

Rodrigo


3 Answers

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.

like image 129
Mohammed Avatar answered Sep 30 '22 16:09

Mohammed


I had the same problem and I fix it following this solution: https://www.unixmen.com/45713-2/ 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=http://192.168.168.180:3128 
    

    Here you wil put your numbers.

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

    vi ~/.bash.rc
    
like image 25
Mariano Cali Avatar answered Sep 30 '22 18:09

Mariano Cali


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
like image 44
Martin Avatar answered Sep 30 '22 16:09

Martin