Sunday, February 14, 2016

Setting our proxy for apt

In Debian/Ubuntu you have the command apt-get to do your updates and installation and it works all fine and well when you have a direct connection to the Internet but once you are behind a proxy you need to set a specific proxy configuration.

The reason why an export http_proxy doesn't have effect is because apt-get is executed in a sudo context and the environment variable is simply ignored. To solve this you need to do the following:

sudo touch /etc/apt/apt.conf

Edit /etc/apt/apt.conf
sudo vi /etc/apt/apt.conf

Add the following content:
Acquire::http::Proxy "http://username:password@proxy:port";

For example:
Acquire::http::Proxy "";

After you have edited the file you need of course to restart the service or reboot the system to take effect. If you get the message "Extra junk at the end of file" it means something is wrong with the syntax like a missing semi-column.

No comments: