How to make wget to work with proxy and proxy authentification

From ArchWiki

Jump to: navigation, search


i18n
English
Español

It is sometimes necessary to run wget inside a network where a proxy requests authentication, or when pacman must use a proxy that requires authentication. The former can be achieved simply by defining two variables, such as in ~/.bashrc (note that this example uses a proxy at 192.168.10.11, listening on port 8080):

export http_proxy="http://192.168.10.11:8080"
export ftp_proxy="http://192.168.10.11:8080"

Then, simply run wget with two extra arguments: --proxy-user="string" --proxy-passwd="string"

For example (Domain name: Wonderwall, username JohnDoe, password Go4It"):

wget --proxy-user "Wonderwall\JohnDoe" --proxy-passwd "Go4It" URL

It is possible to set an alias, which can again be done in ~/.bashrc, such as:

alias wget 'wget --proxy-user "Wonderwall\JohnDoe" --proxy-passwd="Go4It"'

Although this is a security risk, as the password is readable by anyone that can read your .bashrc file, or view your set aliases. Conversely, on any system where someone can read the entire /proc tree, it is possible to view any argument passed on the command line, such as the username and password.

Alternatively, you may set the username/password in the http_proxy/ftp_proxy variables:

export http_proxy="http://wonderwall\\johndoe:Go4It@192.168.10.11:8080"
export ftp_proxy="http://wonderwall\\johndoe:Go4It@192.168.10.11:8080"

To have pacman automatically use wget and the proxy, define the environment variables (such as in ~/.bashrc) and place the wget command into /etc/pacman.conf, in the [options] section:

XferCommand = /usr/bin/wget --proxy-user "domain\user" --proxy-passwd="password" --passive-ftp -c -O %o %u
Personal tools