In order to have console applications use a proxy, the easiest way is to set the proxy in system environment, this can either be done by using command line:
1 2 3 |
export http_proxy=http://<proxy>:<port> export https_proxy=http://<proxy>:<port> sudo -E add-apt-repository ppa:linaro-maintainers/toolchain |
Or simply to set it by setting “Network Proxy” in system settings (Can be found in network panel in Ubuntu 18.04, which may also work on other Linux distributions, but the export command always work.)
After above setting, the system setting will work for many software including wget, etc. however, certain software will be stubborn enough to connect to the Internet directly without the proxy, such as apt-get and apt-apt-repository, apt-get can set its own proxy by configuring
1 |
/etc/apt/apt.conf |
Just as my previous post mentioned.
There is one way to solve the problem:
In addition to configuring proxies, tell sudo
to preserve the environment with the -E
option:
1 2 3 4 5 6 |
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> |
Notice: -E can be replaced with: -E, --preserve-env
HERE, you will be able to find further instruction:
https://askubuntu.com/questions/53146/how-do-i-get-add-apt-repository-to-work-through-a-proxy