Installing a Tor Relay from Source on a Raspberry Pi
Posted on Sat 03 September 2016 in Uncategorized
The other day I learned on Twitter that I should update the Tor relay
software on my Raspberry Pi as the Tor project had introduced a new
Bridge Authority. So I lazily ran sudo apt-get update
followed by sudo apt-get upgrade only to notice that no new version of the tor package was
available via the package manager. Bummer.
Waiting for the package manager to provide a new version seemed futile so I decided to build Tor from scratch. I found a very helpful answer on StackOverflow that listed all the steps required for my setup.
-
Make sure to have all dependencies needed for compiling the sources:
sudo apt-get install git build-essential automake libevent-dev libssl-dev -
Clone Tor from
git.torproject.org:git clone https://git.torproject.org/tor.git -
Go into the tor directory:
cd tor -
Switch to the latest release branch:
git checkout release-x.y.z -
Run
./autogen.sh - Run
./configureor./configure --disable-asciidocif you don't want to build the manpages. - Run
make - (Optiona): run
make install
This last step installed the new tor binary in /usr/local/bin/ whereas
the existing tor binary was still located in /usr/bin/ from where it
was picked up by /etc/init.d/tor (I want to run my tor relay as a
service whenever the Raspberry reboots). Luckily, this problem had been
solved by someone else who shared his findings on a mailing
list.
-
If you're using `service tor {start, stop, reload, etc.}:
$ /usr/bin/tor --version; /usr/local/bin/tor --version $ grep DAEMON=/etc/init.d/tor -
The latter will likely point to
/usr/bin/tor, which might be outdated.
If that's the case, change that line in/etc/init.d/torto point to the new Tor executable/usr/local/bin/tor- that's where it should be; if you don't like that, changeBINDIR = /usr/local/binin Tor's Makefile andmake installagain. -
The Debian Tor packages seem to like to assume
torrcwill be placed in/etc/tor/torrc. If that's where yourtorrcresides, make a symlink to it from/usr/local/etc/tor, which is where the new Tor executable will look for it:ln -s /etc/tor/torrc /usr/local/etc/tor/torrc -
Stop the running tor service:
sudo /etc/init.d/tor stop -
Reload the tor daemon:
sudo systemctl daemon-reload -
Restart the tor service:
sudo /etc/init.d/tor start