How do I proxy my Linux device through Tor?
Wanting to hide the devices/server's IP address by running it through Tor? No problem, its super easy to get setup.
This was specifically tested on a Raspberry Pi, but it should work perfectly fine on just about any Linux device.
1. First thing you will need is Tor, so lets show you how to install that.
2. Open up terminal or connect to the command line through ssh.
3. Type apt update && apt full-upgrade -y
to make sure everything is updated before we start.
4. Now type apt install tor -y
5. After Tor installs successfully, type nano /etc/tor/torrc
to edit your Torrc file. You can also edit the file using software such as Filezilla.
6. Once you open your Torrc file, goto the bottom of the file and add these lines:
SOCKSPort 9050
SOCKSPolicy accept *
7. Now save the file and type sudo service tor restart
to restart Tor.
8. Now type nano /etc/environment
and add these lines:
http_proxy="socks5://127.0.0.1:9050"
https_proxy="socks5://127.0.0.1:9050"
9. Save the file and type the command nano ~/.bashrc
and add these lines to it and save:
export http_proxy="socks5://127.0.0.1:9050"
export https_proxy="socks5://127.0.0.1:9050"
10. Finally, type source ~/.bashrc
for these changes to take effect.
You're done, but one big issue I personally ran into was system updates won't work because they don't get along with Tor very well.
To fix this we can make it where everything will run through Tor besides when we use the apt command for updates.
So, to do this simply follow along:
1. Type sudo nano /etc/apt/apt.conf
2. Then add these lines to the file and save:
Acquire::http::Proxy "DIRECT";
Acquire::https::Proxy "DIRECT";
Thats it. You can now run apt update && apt full-upgrade -y
and they should succeed since it won't update through Tor.
To make sure your device's IP address is being hidden you can use this command:
curl https://myip.wtf/json