π§ Setup a Tor Relay
This guide walks through setting up a non-exit Tor relay on Debian, including:
- automatic security updates
- Tor installation
- relay configuration
- monitoring
π 1. Enable Automatic Updates
Keeping your server updated is critical.
Update packages
apt update
apt install unattended-upgrades apt-listchanges
Configure unattended upgrades
nano /etc/apt/apt.conf.d/50unattended-upgrades
Replace the Allowed-Origins section with:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
"TorProject:${distro_codename}";
};
Unattended-Upgrade::Automatic-Reboot "true";
Test it
unattended-upgrade --debug
π§ 2. Install Tor
Install prerequisites
apt install apt-transport-https
Check your Debian version
cat /etc/debian_version
Add Tor repository
nano /etc/apt/sources.list.d/tor.list
Add:
deb [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org {yourdistro} main
deb-src [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org {yourdistro} main
π Replace {yourdistro} with your Debian codename (e.g. bookworm)
Add GPG key
wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc \
| gpg --dearmor \
| tee /usr/share/keyrings/tor-archive-keyring.gpg >/dev/null
Install Tor
apt update
apt install tor deb.torproject.org-keyring
βοΈ 3. Configure Tor Relay
Open config file
nano /etc/tor/torrc
Example relay configuration
## RELAY IDENTITY
Nickname MyRelay
ContactInfo your@email
## NETWORK
ORPort 443
ExitRelay 0
SocksPort 0
## BANDWIDTH LIMIT (β800GB/month)
AccountingMax 800 GB
AccountingStart month 1 0:00
## BANDWITH SPEED LIMIT
RelayBandwidthRate 10 MB
RelayBandwidthBurst 20 MB
## MONITORING
ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1
π This config creates a non-exit relay (safer, recommended for beginners)
Enable and start Tor
systemctl enable tor
systemctl restart tor
π 4. Monitor Your Relay
Install Nyx
apt install nyx
Run Nyx
nyx
π Nyx provides:
- real-time bandwidth usage
- relay status
- connection stats
β Final Notes
- Allow port 443 in your firewall
- Port forward if behind a router
- Give it time (relay needs hours/days to be fully recognized)
π Conclusion
You now have a working Tor relay with:
- automatic updates π
- controlled bandwidth π
- monitoring tools π§
Running a relay helps support privacy and decentralization on the internet.
Questions / idea? Open an issue on GitHub.