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

DescriptionCommand

Install Tor From the Official Repository
1

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"
2Pull 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
3Export the key and add to apt, this enables package verification
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
4Update the package cache with tor repositories added as sources
sudo apt-get update
5Install tor
sudo apt-get install tor deb.torproject.org-keyring -y
6Add your current user to the debian-tor group to be able to use cookie authentication
sudo usermod -a -G debian-tor $USER
7Run 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"

Create and Execute Tor Script
8

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

Restart Zend and Check Network Configuration

9Stop 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
10

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


Example Output

{
"name": "onion",
"limited": false,
"reachable": true,
"proxy": "127.0.0.1:9050",
"proxy_randomize_credentials": true
}
],
"relayfee": 0.00000100,
"localaddresses": [
{
"address": "xxxxxxxxxxxxxxxxxx.onion",
"port": 9033,
"score": 5
}


Optional - Add Nodes
11

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
Example Output

rpcuser=XXXXXXXXXXXXXXXX
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
rpcport=18231
rpcallowip=127.0.0.1
server=1
daemon=1
listen=1
txindex=1
logtimestamps=1
### testnet config
#testnet=1
tlscertpath=/etc/letsencrypt/live/node01.zentest.win/cert.pem
tlskeypath=/etc/letsencrypt/live/node01.zentest.win/privkey.pem
externalip=123.123.123.123
externalip=2123:423:1c23:1823::1
port=9033
addnode=664sm6tboxgulaar.onion
addnode=k6yjiqxfehnbey5x.onion
addnode=ktp7b3ffc324zeoq.onion
addnode=k4mndsz24sj2fk7w.onion
addnode=52ywlur6mlmpl62j.onion
addnode=e5nntkmas4nxxhxd.onion
addnode=ifmrspt373jdl6b6.onion
addnode=4mt3rihnc6jmud3b.onion



© 2020 Horizen. All rights reserved.