fir3net
PPS-Firenetbanner-780.5x190-30-03-17

How do I run apt-get when Im behind a proxy ?

In order configure your Ubuntu/Debian box to access HTTP, HTTPS and FTP via a Proxy you will need to assign some environment variables.

Assign Environmental Variables

Below shows you the different variables you need to declare :

export HTTP_PROXY=[PROXY IP]:[PORT]
export HTTPS_PROXY=[PROXY IP]:[PORT]
export FTP_PROXY=[PROXY IP]:[PORT]

Survive reboot

To survive a reboot you need to add these to /etc/bash.bashrc

echo export HTTP_PROXY=http://[PROXY IP]:[PORT] >> /etc/bash.bashrc
echo export HTTPS_PROXY=https://[PROXY IP]:[PORT] >> /etc/bash.bashrc
echo export FTP_PROXY=ftp://[PROXY IP]:[PORT] >> /etc/bash.bashrc

User Authentication

Below is an example if you need to add authentication credentials:

HTTP_PROXY=http://[USERNAME]:[PASSWORD]@[PROXY IP]:[PORT]

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001