How to Set Up Proxy with Username/Password and Encode Special Characters in Linux
This guide explains how to configure HTTP and HTTPS proxy environment variables with username and password authentication on Linux, including the conversion of special characters in passwords to their percent‑encoded ASCII representations, and provides a reference table of common ASCII codes.
As a developer, you may occasionally need terminal access to external resources or set up a proxy for service testing.
This time, because of username and password authentication, after some searching I finally solved it and share the solution.
First, the general format for configuring a proxy:
export http_proxy=http://username:password@proxy_address:proxy_port
export https_proxy=https://username:password@proxy_address:proxy_portIf the password contains special characters (which is common), you need to convert those characters to their ASCII code form, represented as % + Hex (omit 0x).
For example:
# Assume:
# Proxy server domain: proxy.com
# Proxy port: 8080
# Username: testuser
# Password: password@123
# @ represented as ASCII code: 0x40, replace with %40
export http_proxy=http://testuser:password%[email protected]:8080
export https_proxy=https://testuser:password%[email protected]:8080Common ASCII codes (others can be searched, e.g., http://ascii.911cha.com/):
@ – 0x40
: – 0x3A
~ – 0x7E
# – 0x23
$ – 0x24
% – 0x25
& – 0x26
This article is reprinted from: "Open Source China", original link: https://tinyurl.com/y4pj6q9b, copyright belongs to the original author.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
