You are here: Home / Debian GNU/Linux / Servers / HTTP / Install the anonymizing proxy server TOR on Debian

Install the anonymizing proxy server TOR on Debian

by Pierre-Yves Landuré last modified Mar 02, 2018 08:35

TOR (aka. The Onion Router) is a network of chained and encrypted proxy servers hiding your true identity to the visited web sites at the cost of a slightly slower download speed. Privoxy add a protection layer to TOR. It blocks ads, referrer and add SOCKS protocol compatibility.

This howto is tested on:

  • Debian 5.0 Lenny
  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy

Installation

To install TOR proxy server quickly, use:

command sh -c 'command apt-get -y install lsb-release gnupg;
if [ -z "$(command grep "Tor system setup" "/etc/sysctl.conf")" ]; then
command echo "# Tor system setup.
fs.file-max=100000" >> "/etc/sysctl.conf"
command sysctl -p
fi
DEBIAN_VERSION=$(command lsb_release -cs);
command echo "# TOR for ${DEBIAN_VERSION}
deb http://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" \
> "/etc/apt/sources.list.d/torproject.list";
command gpg --keyserver keys.gnupg.net --recv 886DDD89;
command gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | command apt-key add -;
command apt-get update;
command apt-get -y install privoxy tor curl;
command echo "forward-socks4a / localhost:9050 ." >> "/etc/privoxy/config";
command sed -i -e "s/^\(listen-address[ \t]*\)[^:]*/\1/" "/etc/privoxy/config";
command sed -i -e "s/^\(debug[ \t]*.*\)/#\1/" "/etc/privoxy/config";
/etc/init.d/privoxy restart'

Step by step installation

Install the installation prerequisites:

command apt-get install lsb-release gnupg

Optimize system parameters for Tor :

if [ -z "$(command grep 'Tor system setup' '/etc/sysctl.conf')" ]; then
command echo "# Tor system setup.
fs.file-max=100000" >> '/etc/sysctl.conf'
command sysctl -p
fi

Detect the distribution name:

DEBIAN_VERSION=$(command lsb_release -cs)

Add the software repository to the apt configuration:

command echo "# TOR for ${DEBIAN_VERSION}
deb http://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" \
    > '/etc/apt/sources.list.d/torproject.list'

Add the repository signing key to apt:

command gpg --keyserver keys.gnupg.net --recv 886DDD89
command gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | command apt-key add -

Update the available packages list:

command apt-get update

Install the software:

command apt-get install tor privoxy

Setup Privoxy to use TOR as SOCKS 4a proxy server. The DNS queries are done over the TOR network:

command echo "forward-socks4a / localhost:9050 ." >> '/etc/privoxy/config'

If necessary, set up Privoxy to allow other hosts to use the proxy server (this can be dangerous):

command sed -i -e "s/^\(listen-address[ \t]*\)[^:]*/\1/" "/etc/privoxy/config"

Disable the debug log:

command sed -i -e "s/^\(debug[ \t]*.*\)/#\1/" '/etc/privoxy/config'

Restart the privoxy server:

/etc/init.d/privoxy restart

Usage

To use the proxy server, setup the HTTP proxy of your web browser with the server IP address and 8118 as connexion port.

The use of TOR to preserve privacy go with limitations:

  • The web pages download speed is slower.
  • Some sites does not allow connexions from the TOR network.
  • TOR users are banned from some IRC channels like #ubuntu on Freenode servers.

Thanks

  • Thanks to TOR developers.