export HTTP_PROXY and special characters in passwd

29,233

Solution 1

You could try URL-encoding your password. @ should be replaced by %40.

Tackling Special Characters in Proxy Passwords on Linux indicates this should work, but looking around other people seem not to get that to work (and I have no way of testing this).

Solution 2

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://unicode-table.com (or) http://unicodelookup.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
Share:
29,233

Related videos on Youtube

Mike Pennington
Author by

Mike Pennington

Updated on September 18, 2022

Comments

  • Mike Pennington
    Mike Pennington almost 2 years

    Suppose for the sake of argument my password below is abc123@

    I need to authenticate my linux machine through a corporate proxy to get patches and updates... normally I'd use this:

    export HTTP_PROXY='http://<Americas\Username>:<Password>@proxy.foo.com'
    export http_proxy='http://<Americas\Username>:<Password>@proxy.foo.com'
    

    However, when I substitute a real password ending with @ and then run aptitude update, I get...

    [mpenning@netwiki ~]$ sudo -E aptitude update
    Err http://mirror.anl.gov squeeze Release.gpg
      Could not resolve '@proxy.foo.com'
    Err http://mirror.anl.gov/debian/ squeeze/main Translation-en
      Could not resolve '@proxy.foo.com'
    

    I have tried escaping the password with \@, escaping both with \@\@, double characters (@@), and nothing seems to get this to proxy correctly; I never had a problem until I changed my password recently.

    What is the right way to escape my password in bash?

  • Jean-Rémy Revy
    Jean-Rémy Revy almost 10 years
    Just to save you time : meyerweb.com/eric/tools/dencoder. Thanks for the tip @Mat