0

What is the correct format using special characters in http_proxy environment variable?
Or to be mor specific, what to do with special characters in username or password when authenticate to http proxy on the command line.

1
  • What do you mean by "special characters"? Commented Feb 15, 2013 at 12:39

3 Answers 3

5

At first, the complete format is:

http_proxy='http://user:pass@server:port/'

Every special character in username and password must not conflict with the characters used in the above format AND must be URL compliant.

Here is an example:

Domain: ADMIN DOM
User:   [email protected]  
PW:     a%b(c/x@y z
Server: proxy.server.at
Port:   8080

becomes:

'http://ADMIN%20DOM\my%40email.address:a%25b(c%2Fx%40y%[email protected]:8080/'

And to prevent bash interpretation of any character always use single-quotes.

You can set this system wide in /etc/environment like this:

http_proxy='http://ADMIN%20DOM\my%40email.address:a%25b(c%2Fx%40y%[email protected]:8080/'

Easy URL encoding/decoding:
https://duckduckgo.com/?q=url+encode+a%25b%28c%2Fx%40y+z&kl=at-de
or
https://duckduckgo.com/?q=url+escaping

1

Even more simple and Reliable!

General Syntax:

sudo {http,https,ftp}_proxy=http://<username>:<password>@<proxy_url/_proxyip>:<port>/ wget --timeout=5 --no-check-certificate http://<website_url>

Example:

[root@localhost ~]# sudo {http,https,ftp}_proxy=http://username:[email protected]:6050/ wget --timeout=5 --no-check-certificate http://google.com

{http,https,ftp}_proxy -> http, https, ftp urls. Seperated by comma.

--timeout=5 -> Connection to keep alive in seconds.

-no-check-certificate -> Ignore SSL / Certificate Verification.

--spider -> If you want to test the connectivity without downloading the file.

Notes:

Online Converter:

Replace special characters with its equivalent hexadecimal unicode. For a list of unicodes refer the website https://unicodelookup.com (or) https://unicode-table.com

Local Converter using Python:

Reference: conversion of password "p@s#w:E" to unicode will be as follows,

@ = %40
$ = %24
# = %23
: = %3A
p@s#w:E = p%40s%23w%3AE

Input:

[root@localhost ~]# python -c "import sys, urllib as enc; print enc.quote_plus(sys.argv[1])" "p@s#w:E"

Output:

p%40s%23w%3AE
0

Suppose your username is foo and your password is bar$.

Quote them:

http_proxy='http://foo:bar$@localhost:3128/' wget http://www.google.com/

Or escape them:

http_proxy=http://foo:bar\$@localhost:3128/ wget http://www.google.com/

What if your password is bar/? URL encode them.

http_proxy="http://foo:bar%2F@localhost:3128/" wget http://www.google.com/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .