Skip to content

Instantly share code, notes, and snippets.

@valyakuttan
Last active April 28, 2024 08:36
Show Gist options
  • Star 60 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • Save valyakuttan/ce4afb62288120cd5ecef0fde4ea63c4 to your computer and use it in GitHub Desktop.
Save valyakuttan/ce4afb62288120cd5ecef0fde4ea63c4 to your computer and use it in GitHub Desktop.

Setup tor proxy on Arch Linux

Copied from this article.

Installation

  1. Install tor

         $ sudo pacman -S tor
         $ ## nyx provides a terminal status monitor for bandwidth usage, connection details and more.
         $ sudo pacman -S nyx
         $ ## torsocks safely torify applications
         $ sudo pacman -S torsocks
  2. Start the tor service

         $ sudo systemctl enable --now tor.service
  3. By default, Tor runs on port 9050. Check it

         $ systemctl status tor.service
         $ ss -nlt

Test Tor Network Connection

  1. Check your current public IP address

         $ wget -qO - https://api.ipify.org; echo
  2. Torify the command through the torsocks

         $ torsocks wget -qO - https://api.ipify.org; echo
         $ ## must show a different ip address

Torify your Shell

  1. torify the shell, issue

         $ source torsocks on
         $ wget -qO - https://api.ipify.org; echo
         $ ## must show the ip address of tor node
  2. To turn on torsocks permanently for all new shells add it to .bashrc

         $ echo ". torsocks on" >> ~/.bashrc
  3. If you want to turn torsocks off, try

         $ source torsocks off

Enable the Tor control port

  1. Add to your /etc/tor/torrc

          ControlPort 9051
  2. Set a Tor Control password

    Convert your password from plain-text to hash

         $ set +o history # unset bash history
         $ tor --hash-password your_password
         $ set -o history # set bash history
  3. Add that hash to your /etc/tor/torrc

         HashedControlPassword your_hash
  4. Restart tor

        $ sudo systemctl restart tor.service
  5. Check the status of port 9051

        $ ss -nlt

Test your tor control port

  1. Install gnu-netcat

          $ sudo pacman -S gnu-netcat
  2. To test your tor use

        $ echo -e 'PROTOCOLINFO\r\n' | nc 127.0.0.1 9051
  3. To request a new circuit (IP address) from Tor, use

        $ set +o history
        $ echo -e 'AUTHENTICATE "my-tor-password"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
        $ set -o history
@larrasket
Copy link

thanks

@vartozeQ-tech
Copy link

Thanks <3

@abzrg
Copy link

abzrg commented Sep 30, 2021

Just needed this. Thanks!!

@alirezabashi98
Copy link

thanks

@GanbaruTobi
Copy link

thanks

@Cohen-Koen
Copy link

Danke!

@nain333
Copy link

nain333 commented Sep 26, 2023

515 Authentication failed: Password did not match HashedControlPassword value from configuration
i'm facing bad authentication please help!
I cross checked the hash after entering, I also restarted the tor service after saving the password to torrc still Im facing this
update: now it's showing the error below:

1695761456 ERROR torsocks[25541]: Unable to resolve. Status reply: 4 (in socks5_recv_resolve_ptr_reply() at socks5.c:823)
1695761456 WARNING torsocks[25541]: [connect] Connection to a local address are denied since it might be a TCPDNS query to a local DNS server. Rejecting it for safety reasons. (in tsocks_connect() at connect.c:191)
Error: Couldn't create connection (err=-5): Operation not permitted 

@omid3699
Copy link

omid3699 commented Oct 8, 2023

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment