The following details a procedure to use tor for any commands used on the command line in Linux. The test env here is a Debian server.
# apt-get install tor
You should create a hashed control password for tor:
#tor --hash-password 'mypassword' Apr 22 21:00:14.198 [notice] Tor v0.2.4.27 (git-412e3f7dc9c6c01a) running on Linux with Libevent 2.0.19-stable and OpenSSL 1.0.1e. Apr 22 21:00:14.198 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning Apr 22 21:00:14.206 [warn] You are running Tor as root. You don't need to, and you probably shouldn't. 16:A08B4CD129C38494608095E8CB6E3CF6FD61987221130F81E49F28783D
Now setup tor options in the control file at /etc/tor/torrc so that it contains the following:
ControlPort 9051 CookieAuthentication 0 HashedControlPassword 16:A08B4CD129C38494608095E8CB6E3CF6FD61987221130F81E49F28783D
Now, Restart the tor service:
service tor restart
Test the current ip:
# curl ifconfig.me 2>/dev/null
Now test the torrized ip:
# torify curl ifconfig.me 2>/dev/null 22.214.171.124
To get a new ip, do this:
echo -e 'AUTHENTICATE "mypassword"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
Here, you’re providing the password which you created earlier.
Test the new ip:
# torify curl ifconfig.me 2>/dev/null 126.96.36.199
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.