Saturday, March 3, 2012

Configure Debian/Ubuntu to work behind a proxy

Add proxy in Network Proxy Preferences (System > Preferences > Network Proxy)


Add proxy in Synaptic Package Manager (System > Synaptic Package manager > Setting > Preferences > Network)


Proxy setting from command line or Gnome-Terminal (aptitude, apt-get)

To configure debian to work behind a proxy using command line, you need to edit apt.conf file :
nano /etc/apt/apt.conf
Then at the end of the file add the following line :
Acquire::http::Proxy "http://proxy-server:port/";
Acquire::ftp::Proxy "http://proxy-host:port/";
If you are using proxy with a password the config file will be (Don`t forget to chnage user:pass with you artual proxy usermane and password)
Acquire::http::Proxy "http://user:pass@proxy-server:port/";
Acquire::ftp::Proxy "http://user:pass@proxy-server:port/"; 
Then, Save and exit.

Proxy setting from command line or Gnome-Terminal (Wget)

You can use the following methods to configure your console to use a proxy server so that console based programs like wget could get connect to the internet through the proxy.


Set the environment variable
# export http_proxy="http://proxy-server:port/"
# export ftp_proxy="http://proxy-server:port/"
or
# export http_proxy="http://user:pass@proxy-server:port/"
# export ftp_proxy=
"http://user:pass@proxy-server:port/"
In the above configuration you can ommit the DOMAIN\USERNAME:PASSWORD@ part if you are not using proxy authentication.
Note: If you get the following error when you try to use wget, you might have to pass the proxy authentication credentials to wget as arguments.
Connecting to SERVER:PORT... connected.
Proxy request sent, awaiting response... 407 Proxy Authentication Required
11:14:45 ERROR 407: Proxy Authentication Required.
Passing proxy authentication credentials to wget as arguments.
$ wget --proxy-user "DOMAIN\USERNAME" --proxy-passwd "PASSWORD" URL
Configure the proxy settings in the .bashrc
If you want set the proxy for all the users you can do it in the system wide .bashrc file.
# nano /etc/bash.bashrc
Add this :
# proxy settings
# export http_proxy="http://proxy-server:port/"
# export ftp_proxy="http://proxy-server:port/"
or
# export http_proxy="http://user:pass@proxy-server:port/"
# export ftp_proxy=
"http://user:pass@proxy-server:port/"
Note: The system wide .bashrc file may not be available in all Linux systems and only can be used if you are using the bash shell 

No comments: