参考How to Configure Proxy Settings on Ubuntu 20.04

命令行运行:

export HTTP_PROXY=[username]:[password]@[proxy-web-or-IP-address]:[port-number]
export HTTPS_PROXY=[username]:[password]@[proxy-web-or-IP-address]:[port-number]
export FTP_PROXY=[username]:[password]@ [proxy-web-or-IP-address]:[port-number]
export NO_PROXY=localhost,127.0.0.1,::1

export http_proxy=[username]:[password]@[proxy-web-or-IP-address]:[port-number]
export https_proxy=[username]:[password]@[proxy-web-or-IP-address]:[port-number]
export ftp_proxy=[username]:[password]@ [proxy-web-or-IP-address]:[port-number]
export no_proxy=localhost,127.0.0.1,::1

大小写都要设置, 因为有的程序认大写, 有些(curl)认小写.
如果需要长期生效, 可以把上面的内容加到~/.bashrc里面
但是这个对apt不起作用. apt要生效, 需要修改文件: /etc/apt/apt.conf,增加:

Acquire::http::Proxy "http://[username]:[password]@ [proxy-web-or-IP-address]:[port-number]";
Acquire::https::Proxy "http://[username]:[password]@ [proxy-web-or-IP-address]:[port-number]";

标签: none 阅读量: 1050

添加新评论