You are here

How to configure Proxy Settings for the Linux Console and APT

Uditha Atukorala's picture

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.

1 - Set the environment variable
# export http_proxy=http://DOMAIN\USERNAME:PASSWORD@SERVER:PORT/
# export ftp_proxy=http://DOMAIN\USERNAME:PASSWORD@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.

1.1 - Passing proxy authentication credentials to wget as arguments
$ wget --proxy-user "DOMAIN\USERNAME" --proxy-passwd "PASSWORD" URL

2 - 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

#proxy settings
export http_proxy=http://DOMAIN\USERNAME:PASSWORD@SERVER:PORT/
export ftp_proxy=http://DOMAIN\USERNAME:PASSWORD@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
2.1 - Having an alias for wget with proxy
If you don't want to pass the proxy arguments to wget all the time, you create an alias for wget in the .bashrc file
alias wget='wget --proxy-user "DOMAIN\USERNAME" --proxy-passwd "PASSWORD"'

Additionally if you want APT to use a proxy server you can configure it in the /etc/apt/apt.conf configuration file.

nano /etc/apt/apt.conf
#
# Proxy configuration
#
Acquire::http::Proxy "http://DOMAIN\USERNAME:PASSWORD@SERVER:PORT";