set-up proxy on linux

Hi everyone!

Here a simple guide to set up a connection via proxy.
If you need to use a proxy to connect to any remote host, you can configure your linux system to use it automatically.
In case of an http proxy, you must write the line below into /etc/environment:

export http_proxy="http://<user>:<pwd>@<host>:<port>"

where “user” is your proxy user, “pwd” is your proxy password, “host” and “port” are the proxy IP and PORT defined to use that proxy connection.

If you need to set other proxy types, you can use the following options:
or all_proxy=.. if you use the same proxy options on all proxy servers.

Enjoy! 😉


APT proxy connection

In some cases I needed to connect to internet through a proxy.
There are many ways to set the proxy data into browsers or other applications, and sometimes the APT needs an own proxy configuration.

If your APT does not connects to internet and you must use a proxy, you need to execute this command:

# echo "Acquire::http::proxy \"http://username:pwd@proxyIP:port\";" >> /etc/apt/apt.conf

where username and pwd are your username and password used to login into proxy server, proxyIP and port are the IP address and port of your proxy server.

If the file /etc/apt/apt.conf is not already present into system, this command creates the file and writes into it.
If the file is already present, it can have a standard line for proxy settings, that you have to modify with your settings or to delete after the execution of the command.

After that, you can test the connection of APT with:

# apt-get update

and you should have a normal update of the repositories.

Enjoy! 😉