My office Internet PCs run Ubuntu. Now and then, I require to install packages on it and I’m behind a proxy server. Below are the methods to configure Proxy settings to apt-get working via the proxy server :
- 1. Configure system wide proxy settings
Go to System Settings –>Network –> Network Proxy. Change the method to Manual and enter the Proxy server IP and port number. But there’s no option to specify the proxy user name and password. So you’ve to edit the /etc/apt/apt.conf file.
user@linux$ sudo vi /etc/apt/apt.conf Acquire::http::proxy "http://username:password@proxyIP:proxyPORT"; Acquire::https::proxy "https://username:password@proxyIP:proxyPORT"; Acquire::ftp::proxy "ftp://username:password@proxyIP:proxyPORT"; Acquire::socks::proxy "socks://username:password@proxyIP:proxyPORT";
- 2. Set the environment variable HTTP_PROXY
user@linux$ export HTTP_PROXY=http://username:password@proxyIP:proxyPORT
To make the changes permanent, append the .bashrc or .profile file with the above command. Verify the setting by running,
Substitute your Proxy username, password and Proxy server’s IP address and its port.
user@linux$ echo $HTTP_PROXY
Any special characters such as $,!,*,^ etc in the password have to be prefixed with a back slash “\” to prevent BASH from interpreting as meta characters. For example, if the proxy password is “s3cr!t”, HTTP_PROXY environment variable should be set from as terminal as
sudo export HTTP_PROXY=http://deepakd:s3cr\!firstname.lastname@example.org:3128
Where 192.168.1.1 is the proxy server and 3128 is the port on which it’s listening.
For more methods refer this askubuntu page.