Behind a corporate proxy? Can't add PPAs to your apt listings?
A typical HTTP proxy URL may look like:
http://proxy.mycoolproxy.com:8080
Let's configure all our tools to use this proxy.
apt
sudo nano /etc/apt/apt.conf.d/00proxy.conf
Acquire::http::Proxy "INSERTPROXYHERE";
Acquire::https::Proxy "INSERTPROXYHERE";
Acquire::ftp::Proxy "INSERTPROXYHERE";
wget
nano ~/.wgetrc
:
use_proxy=yes
http_proxy=INSERTPROXYHERE
https_proxy=INSERTPROXYHERE
curl
nano ~/.curlrc
:
proxy=INSERTPROXYHERE
pip (and others)
nano ~/.bashrc
:
http_proxy=INSERTPROXYHERE
https_proxy=INSERTPROXYHERE
ftp_proxy=INSERTPROXYHERE
You can alternatively use apt install and pip install with a proxy on a one-off basis like so:
sudo http_proxy=INSERTPROXYHERE apt install whatever
pip install --proxy INSERTPROXYHERE whatever
Here's how to install python via the deadsnakes PPA, without using apt-key add
or add-apt-repository
(neither of which seem to work when behind proxy; maybe because they use HKPS protocol instead of HTTP, so don't honour proxy settings?):
Note: replace "focal
" with whatever Ubuntu distribution you have, according to lsb_release -a
.
curl -sSL 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xF23C5A6CF475977595C89F51BA6932366A755776' | gpg --import
gpg --export F23C5A6CF475977595C89F51BA6932366A755776 | sudo tee /usr/share/keyrings/deadsnakes.pgp
echo "deb [signed-by=/usr/share/keyrings/deadsnakes.pgp] https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu focal main" | sudo tee /etc/apt/sources.list.d/deadsnakes.list
sudo apt update
sudo apt install python3.11 python3.11-venv python3.11-distutils
python3.11 -m ensurepip
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
sudo update-alternatives --install /usr/bin/pip pip /home/abirch/.local/bin/pip3 1
nano ~/.bashrc
PATH="$USER/.local/bin:$PATH"