Install Tor

Install Tor

Install Tor and Enable Tor Networking for the Zend Daemon

  • Install Tor From the Official Repository

  • Create and Execute Tor Script

  • Restart Zend and Check Network Configuration

  • Optional - Add Tor Nodes into zen.conf

Description

Command

Description

Command

1

Install Tor From the Official Repository

2

Add the Tor repository to your package sources

sudo su -c "echo 'deb https://deb.torproject.org/torproject.org '$(lsb_release -c | cut -f2)' main' > /etc/apt/sources.list.d/torproject.list"
3

Pull the gpg key used to sign the tor packages

Pulling the gpg key may take some time, if it times out, run it again until it has been imported

curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import
4

Export the key and add to apt, this enables package verification

gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
5

Update the package cache with tor repositories added as sources

sudo apt-get update
6

Install tor

sudo apt-get install tor deb.torproject.org-keyring -y
7

Add your current user to the debian-tor group to be able to use cookie authentication

sudo usermod -a -G debian-tor $USER
8

Run the sg command with bash to start a new shell, this is required for bash to identify the non-root user being added to the debian-tor group (it prevents having to exit and login)

sg debian-tor -c "bash"
9

Create and Execute Tor Script

10

Update the torrc file to make tor work with the zen daemon

  • Some tor repo updates make changes to the torrc file, this script is intended to repair the tor service for zend

The following block of text is meant to be copied and pasted in its entirety

cat <<EOF > ~/tor.sh #!/bin/bash sudo sed -i 's/#ControlPort 9051/ControlPort 9051/g' /etc/tor/torrc sudo sed -i 's/#CookieAuthentication 1/CookieAuthentication 1/g' /etc/tor/torrc sudo su -c "echo 'CookieAuthFileGroupReadable 1' >> /etc/tor/torrc" sudo su -c "echo 'LongLivedPorts 9033' >> /etc/tor/torrc" sudo systemctl restart tor.service EOF



chmod u+x ~/tor.sh



sudo ~/tor.sh
11

Restart Zend and Check Network Configuration

12

Stop zend and the tracker using systemd or with pm2 & monit and apply ownership to the non-root user of all files created since step 7, to enable tor in the zend daemon

For installations using systemd

sudo systemctl stop zend zentracker && sleep 30 && chown -R $USER:$USER ~/ && sudo systemctl start zend zentracker

For installations using monit (zend) and pm2 (tracker)

sudo monit stop zend && pm2 stop 0 && sleep 30 && chown -R $USER:$USER ~/ && sudo monit start zend && sleep 8 && pm2 start 0
13

Verify that tor is enabled in zend by checking the network info

  • See the example output, the important details being in bold

zen-cli getnetworkinfo



14

Optional - Add Nodes

15

Use nano and append tor nodes to the bottom of your zen.conf

  • Save and exit with CTRL+x, type y, then hit enter

NOTE: You will need to restart zend for changes to take effect

nano ~/.zen/zen.conf