Horizontal Navigation

Monday, 28 November 2016

Proxy Setting for apt-get and wget in Ubuntu

If you are using Internet through your Institutions Proxy Server, then set up proxy in the following files of Ubuntu 
To check if you have proxy configured in your system:
env | grep proxy
First Method:
To setup proxy, add the following lines to these environment settings:


1) apt.conf (for apt-get)
sudo gedit /etc/apt/apt.conf
Acquire::http::Proxy "http://username:password@proxy:port";
Acquire::https::Proxy "http://username:password@proxy:port";
Acquire::ftp::Proxy "http://username:password@proxy:port";
2) wgetrc (for wget)
sudo gedit /etc/wgetrc
Then uncomment the following three lines:
https_proxy  = http://username:password@proxy:port
http_proxy = http://username:password@proxy:port
ftp_proxy = http://username:password@proxy:port
Uncomment 'use_proxy = on'

Then reboot. sudo reboot


After rebooting your machine, you can now use apt-get and wget normally like sudo apt-get install package-name and wget url

Second Method:
If you don't want to change any configurations and just wanted to use proxy for the entire duration of your session:
For apt-get:
sudo http_proxy='http://username:password@proxy:port' apt-get install package-name
For wget:
export http_proxy='http://username:password@proxy:port' && wget url

OR
export http_proxy=http://proxy:port && wget --proxy-user=user --proxy-password=password url
Things to remember: 
1) Use this format if your proxy doesn't require login credentials: http://proxy:port
2) If your proxy server is Windows-based just like ours, don't forget to add your domain in your login.
ex. http://domain\username:password@proxy:port
3) Character escape your password if it has special characters.
ex. proxy-password=me\@123
4) If after setting up the http_proxy environment variable for wget and the connection still fails, also set up the https_proxy and ftp_proxy variables.
References: 
1. http://askubuntu.com/questions/664777/systemwide-proxy-settings-in-ubuntu
2. http://annelagang.blogspot.in/

No comments:

Post a Comment