How do I get add-apt-repository to work through a proxy?
In addition to configuring proxies, tell sudo
to preserve the environment with the -E
option:
export http_proxy=http://<proxy>:<port>
export https_proxy=http://<proxy>:<port>
sudo -E add-apt-repository ppa:linaro-maintainers/toolchain
with username and password:
export https_proxy=https://<username>:<password>@<proxy>:<port>
Use the following code in a terminal to add gpg key behind proxy,
sudo apt-key adv --keyserver-options http-proxy=http://USER:PASSWORD@PROXY_URL:PORT/ --keyserver keyserver.ubuntu.com --recv-keys GPG_KEY
And replace uppercase letters accordingly. If you are using a proxy without any user authentication (i.e., user name and password) use http-proxy=http://PROXY_URL:PORT/
instead.
For example to have GPG_KEY=C2514567EEA14886
you can use,
sudo apt-key adv --keyserver-options http-proxy=http://user:[email protected]:3128/ --keyserver keyserver.ubuntu.com --recv-keys C2514567EEA14886
where,
USER_ID=user
PASSWORD=abc123
PROXY_URL=10.10.2.21
PORT=3128
If you don't have user authentication simply use,
sudo apt-key adv --keyserver-options http-proxy=http://10.10.2.21:3128/ --keyserver keyserver.ubuntu.com --recv-keys C2514567EEA14886
Finally! You need to set https_proxy via:
export https_proxy=....
only set http_proxy is not enough.
And I needed to execute the add-apt-repository command as root, NOT via sudo.
Code:
sudo su
add-apt-repository ppa:........