Introduction
In an era of mass surveillance and data tracking, maintaining online privacy is more crucial than ever. One of the most effective ways to anonymize your internet traffic is by using Tor (The Onion Router). While many users rely on the Tor browser, you can also leverage Tor via the command line interface (CLI) on Ubuntu to route your internet activity securely.
This guide will walk you through setting up and configuring Tor on Ubuntu, allowing you to use it as a SOCKS proxy, tunnel your applications through it, and even anonymize your SSH connections. Whether you're a privacy advocate, researcher, or just someone who values anonymity, this tutorial will help you maximize your security online.
Setting Up and Running the Tor Service
Before using Tor, you need to install and enable the service on your Ubuntu system.
Installing Tor
Run the following command to install Tor:
sudo apt update && sudo apt install tor -y
Starting and Enabling Tor
Once installed, start the Tor service:
sudo systemctl start tor
Enable Tor to start automatically on boot:
sudo systemctl enable tor
Check if Tor is running:
systemctl status tor
If the status shows "active (running)," your Tor service is up and running.
Using Tor as a SOCKS Proxy
By default, Tor runs a SOCKS5 proxy on 127.0.0.1:9050
, which you can use to anonymize internet traffic from applications that support SOCKS5.
Verifying Tor is Working with cURL
To check if Tor is routing your traffic, use cURL:
curl --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/api/ip
If configured correctly, this command should return a different IP address than your real one.
Configuring Firefox to Use Tor
- Open Firefox Settings.
- Navigate to General > Network Settings.
- Select Manual proxy configuration.
- Set SOCKS Host to
127.0.0.1
, and Port to9050
. - Check SOCKS v5 and enable Proxy DNS when using SOCKS v5.
- Save settings and restart Firefox.
Now, all your Firefox traffic will be routed through Tor.
Using Privoxy to Route HTTP Traffic through Tor
Some applications do not support SOCKS proxies. In such cases, you can use Privoxy, which converts HTTP traffic into SOCKS5-compatible traffic for Tor.
Installing and Configuring Privoxy
- Install Privoxy:
sudo apt install privoxy -y
- Edit the Privoxy configuration file:
sudo nano /etc/privoxy/config
- Add the following line at the end:
forward-socks5t / 127.0.0.1:9050 .
- Restart Privoxy:
sudo systemctl restart privoxy
Now, you can use http://127.0.0.1:8118
as an HTTP proxy for applications that require it.
Using ProxyChains to Tunnel All Traffic through Tor
If you want to force all command-line applications to use Tor, ProxyChains is an effective solution.
Installing and Configuring ProxyChains
- Install ProxyChains:
sudo apt install proxychains -y
- Edit the configuration file:
sudo nano /etc/proxychains.conf
- Add or modify the following line at the end:
socks5 127.0.0.1 9050
- Save and exit the file.
Using ProxyChains
To route a command through Tor, prepend it with proxychains
. Examples:
proxychains curl https://check.torproject.org
proxychains firefox
This ensures all traffic from the specified application goes through Tor.
Anonymizing SSH Connections via Tor
If you need to securely SSH into a remote server without revealing your real IP, you can use torify
:
torify ssh user@server.com
This command forces the SSH connection through the Tor network, adding an extra layer of anonymity.
Accessing the Dark Web with Tor
Tor allows you to visit .onion
sites, which are only accessible within the Tor network.
Using Torsocks for CLI-Based Browsing
You can use torsocks
to browse .onion
sites from the command line:
torsocks curl http://example.onion
Using the Tor Browser
For a graphical experience, you can install and use the Tor browser:
tor-browser
This gives you full access to the Tor network, allowing you to browse anonymously.
Conclusion
Using Tor via CLI on Ubuntu is a powerful way to maintain online privacy and anonymity. By configuring it as a SOCKS proxy, using Privoxy for HTTP traffic, employing ProxyChains for command-line applications, and even anonymizing SSH connections, you can significantly reduce your online footprint.
For additional security, consider combining Tor with a VPN for an extra layer of protection. As always, be mindful of your activities while using Tor—while it enhances privacy, it does not grant complete immunity from surveillance if misconfigured.
Stay anonymous and browse securely! 🚀