在 passwd 中导出 HTTP_PROXY 和特殊字符

Thi*_*his 8 bash password proxy escape-characters

假设为了论证,我下面的密码是 abc123@

我需要通过公司代理对我的 linux 机器进行身份验证以获取补丁和更新......通常我会使用这个:

export HTTP_PROXY='http://<Americas\Username>:<Password>@proxy.foo.com'
export http_proxy='http://<Americas\Username>:<Password>@proxy.foo.com'
Run Code Online (Sandbox Code Playgroud)

但是,当我替换一个真实的密码以结尾@然后运行时aptitude update,我得到...

[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'
Run Code Online (Sandbox Code Playgroud)

我试过用 转义密码\@,用\@\@双字符 ( @@)转义密码,但似乎没有任何东西可以正确代理;我从来没有遇到过问题,直到我最近更改了密码。

在 中转义我的密码的正确方法是什么bash

Mat*_*Mat 16

您可以尝试对密码进行URL 编码@应替换为%40.

在 Linux 上处理代理密码中的特殊字符表明这应该有效,但环顾其他人似乎并没有让它起作用(我无法测试)。