setting up http proxy for cli

On February 22, 2010, in General, Linux, by Jay

Okay, I have to google this information every-time I need it, to so am going to blog it, so that I know exactly where to look for it :)

Setting up a proxy from the GUI on you browser or system does not always work for command line utilities like apt-get, yum, wget or customer bash scripts etc…

So here is how to setup proxy for CLI from CLI, assuming your proxy server is proxy.example.com (IP 192.168.2.252) and port 3128.
export http_proxy='http://proxy.example.com:port/'

OR
export http_proxy='http://192.168.2.252:3128/'

If you need authentication:
export http_proxy=http://username:password@proxy.example.com:port

If you need to unset it:
echo $http_proxy=''

If need to check if there is already proxy configured:
echo $http_proxy

This change is non-persistent, meaning you will have to redo it after reboot. If you need the configuration to be persistent across reboots. Add the above command to your system /etc/bash.bashrc.
export http_proxy=http://username:password@proxy.example.com:port

You can also add a ftp proxy using a similar entry. Ofcourse check with your admin if the proxy supports ftp.
export ftp_proxy=http://username:password@proxy.example.com:port

Hope this helps someone. Cheers!

 

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Categories