This guide covers:
- Installing Tor
- Configuring Tor settings
- Setting up a Hidden Service
- Configuring the Control Port (with/without password)
- Setting the SOCKS Port
- Configuring the Service Port and Target Port
- Finding the
.onion
hostname
sudo apt update
sudo apt install tor -y
brew install tor
sudo nano /etc/tor/torrc
nano /opt/homebrew/etc/tor/torrc
The Control Port allows applications to talk to Tor.
ControlPort 9051
CookieAuthentication 0
This allows unrestricted access—use it only for testing.
- Generate a hashed password:
Example output:
tor --hash-password "yourpassword"
16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C
- Add it to
torrc
:ControlPort 9051 HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C
- Enable cookie authentication in
torrc
:ControlPort 9051 CookieAuthentication 1
- Restart Tor:
sudo systemctl restart tor
- The cookie file is usually located at:
/var/lib/tor/control_auth_cookie
- Use it in your applications for authentication.
Tor acts as a SOCKS5 Proxy for anonymous traffic.
Add this to torrc
:
SOCKSPort 9050
Now, you can route applications through 127.0.0.1:9050
.
To test it:
curl --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/
5. Setting Up a Hidden Service
A Hidden Service lets you host a .onion
website or server.
Basic Hidden Service (Port Forwarding)
HiddenServiceDir /var/lib/tor/coinswap/
HiddenServicePort 6102 127.0.0.1:6102
HiddenServiceDir /opt/homebrew/var/lib/tor/coinswap
HiddenServicePort 6102 127.0.0.1:6102
Provide required permissions
create sudo mkdir -p /opt/homebrew/var/lib/tor/coinswap
chmod 700 coinswap
- Service Port (Virtual Port):
6102
(Clients use this to connect to the hidden service) - Target Port:
127.0.0.1:6102
(Local port where traffic is redirected)
Tor run the taker client, hidden service is not required.
After configuring, restart Tor:
sudo systemctl restart tor
brew services restart tor