Skip to content

Instantly share code, notes, and snippets.

@antiops
Last active November 11, 2020 05:39
Show Gist options
  • Save antiops/a53a7983876b23c975d884196d37397d to your computer and use it in GitHub Desktop.
Save antiops/a53a7983876b23c975d884196d37397d to your computer and use it in GitHub Desktop.
Tor relay install script
## Install Tor relay as non-root user in home folder
# Verify TORVER is latest stable version
# https://www.torproject.org/download/tor/
TORVER=0.4.4.5
TORDIR=$HOME/opt/tor
NYXDIR=$HOME/opt/nyx
echo '[INFO] Installing Tor'
mkdir -p TORDIR && cd ~/opt
wget https://dist.torproject.org/tor-$TORVER.tar.gz
tar xzvf tor-$TORVER.tar.gz && cd tor-$TORVER
mkdir -p $TORDIR/var/log/tor
mkdir -p $TORDIR/etc/tor
./configure --prefix=$TORDIR
make && make install
# Incremental relay names
# + use non-default ports
echo '[INPUT] Enter Tor Relay # (a9TorRelayX) ie: 01'
read relaynumber
cat <<EOT >> $TORDIR/etc/tor/torrc
SocksPort 0
RunAsDaemon 1
ORPort 59001
Nickname a9TorRelay$relaynumber
ContactInfo tor(at)a9(dot)wtf
Log notice file $TORDIR/var/log/tor/notices.log
DirPort 59030
ExitPolicy reject6 *:*, reject *:*
DisableDebuggerAttachment 0
ControlPort 59051
CookieAuthentication 1
EOT
echo '[INFO] Tor Relay Installed'
# Install Nyx - Tor relay monitoring tool
# https://nyx.torproject.org/#download
echo '[INFO] Installing Nyx'
git clone https://git.torproject.org/nyx.git $NYXDIR
pip install nyx # stem?
echo -e '[INFO] Nyx Installed\n================================================================='
echo '[INFO] Start Tor Relay: $TORDIR/bin/tor -f $TORDIR/etc/tor/torrc'
echo '[INFO] Add Reboot Crontab: @reboot $TORDIR/bin/tor -f $TORDIR/etc/tor/torrc'
echo '[INFO] Load Nyx: $NYXDIR/run_nyx -i 127.0.0.1:59051'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment