How to setup http/https proxy with special characters in password


Written by - Deepak Prasad

In this tutorial I will share the steps to setup http_proxy or https_proxy when your username or password contains special characters such as comma, @, # etc.

 

Error: Unable to set http_proxy or https_proxy with special characters in username or password

Normally while exporting http_proxy or https_proxy we are supposed to provide the username and password along with the proxy IP and port. It would work in most cases but if the username or password contains some special characters then you may get

        Resolving s... failed: Name or service not known.
        wget: unable to resolve host address “s”

The error output may vary depending upon the character involved in the username or password. There are two ways you can overcome this error:

 

Solution-1: Convert text to hex unicode

You must use mapping "hexadecimal unicode" values of respective special characters in the proxy username and password. To get the list of mapping Unicode characters follow https://unicodelookup.com/

For example, a password such as "P@$$\/\/0,#" can be converted into

P ⇒ P  <-- No lookup required
@ ⇒ 0x40
$ ⇒ 0x24
$ ⇒ 0x24
\ ⇒ 0x5C
/ ⇒ 0x2F
\ ⇒ 0x5C
/ ⇒ 0x2F
0 ⇒ 0  <-- No lookup required
, ⇒ 0x2C
# ⇒ 0x23

So if we combine this for "P@$$\/\/0,#" we get "P0x400x240x5C0x2F0x5C0x2F00x2C0x23"

Now you can export your http_proxy:

# export http_proxy="http://username:P0x400x240x5C0x2F0x5C0x2F00x2C0x23@server:port/"

Similarly to export https_proxy

# export https_proxy="https://username:P0x400x240x5C0x2F0x5C0x2F00x2C0x23@server:port/"

 

Solution-2: Provide username and password with wget

Instead of going through the conversion you can also provide the username and password in plain text format with wget command

# wget -e use_proxy=yes -e https_proxy=10.xx.xx.xx:8080 --proxy-user='user' --proxy-password='P@$$\/\/0,#' https://domain.com/file

From the man page of wget:

--proxy-user=user
--proxy-password=password
           Specify the username user and password password for authentication on a proxy server.  Wget will encode them
           using the "basic" authentication scheme.

This solution is only valid if you plan to use wget or else to apply system wide proxy you can use Solution 1 where either username or password has any special characters.

 

Conclusion

In this tutorial I shared the steps to configure http_proxy and https_proxy when username and/or password section contains any special characters. In the provided unicode page you can search for your char and then look out for hexadecimal unicode value of the respective char. Next just replace the special character with the unicode value and you would be able to export the proxy in your Linux server.

 

References

I have used below external references for this tutorial guide
How to export the variable "http_proxy" when there are special characters in password?

 

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can reach out to him on his LinkedIn profile or join on Facebook page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

1 thought on “How to setup http/https proxy with special characters in password”

  1. solution 3: urlencode password, so “P@$$\/\/0,#” would become “P%40%24%24%5C%2F%5C%2F0%2C%23”

    It’s more convenient if just few chars are “special”

    Reply

Leave a Comment

X