NOTE: There is a bash script that takes care of everything in this article and more.
While most of you are familiar with Tor Browser, few are aware that it is a bundle that consists of two parts: the browser and the router. You can use the router to use commands like tor
, torify
and torsocks
tor.list
file inside /etc/apt/sources.list.d/
1sudo touch /etc/apt/sources.list.d/tor.list
1# /etc/apt/sources.list.d/tor.list
2deb [arch=$(dpkg --print-architecture) https://deb.torproject.org/torproject.org $(lsb_release -c | cut -f2) main
3deb-src [arch=$(dpkg --print-architecture) https://deb.torproject.org/torproject.org $(lsb_release -c | cut -f2) main
$(dpkg --print-architecture)
will give you system architecture, e.g. amd64 (keep in mind that Ubuntu Focal dropped support for 32-bit)$(lsb_release -c | cut -f2)
will give you distribution codename, e.g. focaltor
package1apt update
2apt install apt-transport-https
3apt install tor
In /etc/tor/torrc
, uncomment the lines #ControlPort 9051
and #CookieAuthentication 1
and change the CookieAuthentication
value from 1
to 0
1sed -i 's/#ControlPort 9051/ControlPort 9051/g' /etc/tor/torrc
2sed -i 's/#CookieAuthentication 1/CookieAuthentication 0/g' /etc/tor/torrc
3
4sudo /etc/init.d/tor restart
1curl ifconfig.me
2
3torify curl ifconfig.me 2>/dev/null
The torify
command can be used to run any command through tor. The redirect to /dev/null
is used because torify generates a handful of warnings on some platforms.
If all goes well, you should see the IP address you’re getting after going through Tor. If not, try restarting the tor service again.