Linux Set Proxy Settings - chaitanyavangalapudi/devops-scripts GitHub Wiki

Proxy settings via command line on Linux

Use below commands on command line to set http/https proxy and no-proxy hosts. proxyhost below can be either HOST URL like mycompany.example.com or IP address like 192.172.33.200. Replace 8080 with your proxy port.

export http_proxy="http://myuser:passwd123\$@proxyhost:8080"
export https_proxy="http://myuser:passwd\$@proxyhost:8080"
export ftp_proxy="http://myuser:passwd\$@proxyhost:8080"
export no_proxy="localhost,127.0.0.0/8,162.12.0.0/12,192.168.0.0./16,127.0.0.1,162.61.71.226"

If your password has any special characters, escape them by using \ as shown above. In case your password has other characters like @ and # , you can replace them using corresponding ascii characters.

p@s#w:E = p%40s%23w%3AE

export https_proxy="http://myuser:p%40s%23w%3AE@proxyhost:8080"

Proxy settings using profile

You can add above statements to .bashrc or .bash_profile file in your home directory (~/.bashrc). If you want it to be global for all users, you can add it to /etc/profile if the username/password are not required for accessing proxy.


References: