Introduction

Users of the Tor network run an onion proxy on their machine. This software connects out to Tor, periodically negotiating a virtual circuit through the Tor network. Tor employs cryptography in a layered manner (hence the 'onion' analogy), ensuring perfect forward secrecy between routers. At the same time, the onion proxy software presents a SOCKS interface to its clients. SOCKS-aware applications may be pointed at Tor, which then multiplexes the traffic through a Tor virtual circuit.

Warning: Tor by itself is not all you need to maintain your anonymity. There are several major pitfalls to watch out for (see: Want Tor to really work?).

Through this process the onion proxy manages networking traffic for end-user anonymity. It keeps a user anonymous by encrypting traffic, sending it through other nodes of the Tor network, and decrypting it at the last node to receive your traffic before forwarding it to the server you specified. One trade off that has to be made for the anonymity Tor provides is that it can be considerably slower than a regular direct connection, due to the large amount of traffic re-routing. Additionally, although Tor provides protection against traffic analysis it cannot prevent traffic confirmation at the boundaries of the Tor network (i.e. the traffic entering and exiting the network).

Installation

Additionally, there is a Qt frontend for Tor in package vidalia. In addition to controlling the Tor process, Vidalia allows you to view and configure the status of Tor, monitor bandwidth usage, and view, filter, and search log messages.

Configuration

To get a better understanding of Tor review the /etc/tor/torrc configuration file. The configuration options are explained in man tor and the Tor website. The default configuration should work fine for most Tor users.

You can set custom file descriptor ulimits for Tor in /etc/conf.d/tor using the TOR_MAX_FD variable. This sets a limit on the maximum number of open files.

By default Tor logs to stdout with a log-level of "notice". If system logging is enabled in the torrc configuration file, it will default to /usr/local/var/log/tor/.

Usage

You can launch it from command line or via a GUI like vidalia.
Start the tordaemon and add it to the DAEMONS array to have it launch at startup.
To use a program over tor, configure it to use 127.0.0.1 or localhost as SOCKS5 proxy, with port 9050 (plain tor with standard settings) or port 9051 (configuration with vidalia, standard settings).
To check if Tor is functioning properly visit the Tor, Harvard or Xenobite.eu websites.

Web browsing

Tor primarily supports Firefox, but can also be used with Chromium and other browsers.

Chromium

Once installed enter in its configuration page. Under the tab Proxy Profiles add a new profile Tor, if ticked untick the option Use the same proxy server for all protocols, then add localhost as SOCKS Host, 9050 to the respective port and select SOCKS v5.

Optionally you can enable the quick switch under the General tab to be able to switch beetween normal navigation and Tor network just by left-clicking on the Proxy SwitchySharp's icon.

HTTP Proxy

Firefox

The FoxyProxy add-on allows you to specify multiple proxies for different URLs or for all your browsing. After restarting Firefox manually set Firefox to port 8118 on localhost, which is where Polipo or Privoxy are running. These settings can be access under Add > Standard proxy type. Select a proxy label (e.g Tor) and enter the port and host into the HTTP Proxy and SSL Proxy fields. To check if Tor is functioning properly visit the Tor Check website and toggle Tor.

Polipo

The Tor Project has created a custom Polipo configuration file to prevent potential problems with Polipo as well to provide better anonymity.

Keep in mind that Polipo is not required if you can use a SOCKS 5 proxy, which Tor starts automatically on port 9050. If you want to use Chromium with Tor, you do not need the Polipo package (see: #Chromium).

Privoxy

You can also use this setup in other applications like messaging (e.g. Jabber, IRC). Applications that support HTTP proxies you can connect to Privoxy (i.e. 127.0.0.1:8118). To use SOCKS proxy directly, you can point your application at Tor (i.e. 127.0.0.1:9050). A problem with this method though is that applications doing DNS resolves by themselves may leak information. Consider using Socks4A (e.g. with Privoxy) instead.

Instant Messaging

In order to use an IM client with tor, we do not need an http proxy like polipo/privoxy. We will be using tor's daemon directly which listens to port 9050 by default.

Pidgin

Browse through preferences -> proxy and edit it to look like

Proxy type SOCKS5
Host 127.0.0.1
Port 9050

From now on pidgin will be using Tor. In some cases, depending on how different accounts are configured in IM services you have set up, you might want to change their proxy settings. Go to Accounts -> Manage Accounts and modify the account you wish, in Proxy tab to read

Proxy type Use Global Proxy Settings

Irssi

Freenode does not recommend that you use Privoxy with Irssi. Instead they recommend using the mapaddress approach and running torify irssi to start it up. Therefore, add the following to /etc/tor/torrc:

mapaddress 10.40.40.40 p4fsi4ockecnea7l.onion

Freenode requires charybdis and ircd-seven's SASL mechanism for identifying to nickserv during
connection. Download cap_sasl.pl, which enables SASL in Irssi, from the Freenode website (i.e. http://www.freenode.net/sasl/cap_sasl.pl) and save it to ~/.irssi/scripts/cap_sasl.pl

Pacman

Pacman download operations (repository DBs, packages, and public keys) can be done using the Tor network. Though relatively extreme, this measure is useful to prevent an adversary (most likely at one's LAN or the mirror) from knowing a subset of the packages you have installed, at the cost of longer latency, lower throughput, possible suspicion, and possible failure (if Tor is being filtered via the current connection).

Warning: It would be arguably simpler for an adversary, specifically one who desires to indiscriminately disseminate malware, to perform his/her activity by deploying malicious Tor exit node(s). Always use signed packages and verify new public keys by out-of-band means.

Running a Tor Exit Node

Any requests from a Tor user to the regular internet obviously need to exit the network somewhere, and exit nodes provide this vital service. To the accessed host, the request will appear as having originated from your machine. This means that running an exit node is generally considered more legally onerous than running other forms of Tor relays. Before becoming an exit relay, you may want to read Tips for Running an Exit Node With Minimal Harrasment.

Configuration

Using the torrc, you can configure which services you wish allow through your exit node.
Allow all traffic:

This will allow Tor to accept DNS requests (listening on port 9053 in this example) like a regular DNS server, and resolve the domain via the Tor network. A downside is that it's only able to resolve DNS queries for A-records; MX and NS queries are never answered. For more information see this Debian-based introduction.

DNS queries can also be performed through a command line interface by using tor-resolve. For example:

$ tor-resolve archlinux.org
66.211.214.131

Using TorDNS for all DNS queries

Since TorDNS might be little slow to use TorDNS for all queries it is advised using dnsmasq to cache the results. So install dnsmasq and modify its configuration file so that it contains:

/etc/dnsmasq.conf

no-resolv
server=127.0.0.1#9053
listen-address=127.0.0.1

This configuration file sets dnsmasq so that listen only the local computer and uses only the TorDNS service. It is now needed to edit resolv.conf so that it uses only the dnsmasq server.

/etc/resolv.conf

nameserver 127.0.0.1

Start the dns server with

# rc.d start dnsmasq

Finally if you use dhcpd you would need to change its settings to that it does not alter the resolv configuration file. Just add this line in the configuration file:

/etc/dhcpcd.conf

nohook resolv.conf

If you already have an nohook line, just add resolv.conf separated with a comma.

Torify

torify will allow you use an application via the Tor network without the need to make configuration changes to the application involved. From the man page:

torify is a simple wrapper that calls tsocks with a tor specific configuration file. tsocks itself is a wrapper between the tsocks library and the application that you would like to run socksified

Torify will not, however, perform DNS lookups through the Tor network. A workaround is to use it in conjunction with tor-resolve (described above). In this case, the procedure for the first of the above examples would look like this:

Troubleshooting

Problem with User value

If the tor daemon failed to start, then run the following command as root (or use sudo)

# tor

If you get the following error

May 23 00:27:24.624 [warn] Error setting groups to gid 43: "Operation not permitted".
May 23 00:27:24.624 [warn] If you set the "User" option, you must start Tor as root.
May 23 00:27:24.624 [warn] Failed to parse/validate config: Problem with User value. See logs for details.
May 23 00:27:24.624 [err] Reading config failed--see warnings above.

Then it means that the problem is with the User value. So proceed with the following steps.

Check the permissions of the directory /var/lib/tor by running

# ls -l /var/lib/

If the permission for /var/lib/tor is as shown below

drwx------ 2 tor tor 4096 May 12 21:03 tor

This means that the directory is owned by the user tor and the group tor.
Change the owner to the user root, and the group root with the command:

# chown -R root:root /var/lib/tor

If you check the permissions again, it should now show

drwx------ 2 root root 4096 May 12 21:03 tor

Now open /etc/tor/torrc and find the following lines

## Uncomment this to start the process in the background... or use
## --runasdaemon 1 on the command line.
RunAsDaemon 1
User tor
Group tor

Comment out the lines User tor and Group tor, so that the lines read as

## Uncomment this to start the process in the background... or use
## --runasdaemon 1 on the command line.
RunAsDaemon 1
#User tor
#Group tor

Save the changes and restart the tor daemon, it should now work.

# rc.d restart tor

Daemon fails on restart

If after issuing /etc/rc.d/tor restart you have log entries similar to

Interrupt: we have stopped accepting new connections, and will shut down in 30 seconds. Interrupt again to exit now

and the daemon fails to start back up, a simple workaround is to open /etc/rc.d/tor in your favourite editor and increase the time waited between the shutting down and starting up again of the daemon. For example:

/etc/rc.d/tor

;;
restart)
$0 stop
sleep 35
$0 start
;;

This will allow Tor to shutdown cleanly, and restart after a safe period of time. Remember that this file may be overwritten by upgrades.