10

I have installed Tor on a command-line only environment without the browser, so I can't use check.torproject.org with a browser. Tor is used by a script to request data from clearnet.

The tor service is used by Privoxy proxy forwarding in order to relay data to my script. It's been working perfectly for months now, but a problem has just occurred in the setup which is preventing my script to access Tor.

I used to use torify/torsocks to see if tor is working, but sadly it appears to be glitchy and torify curl http://.... doesn't seem work anymore. I know that The tor process is listening, but I have no way to see if it's working and troubleshoot the problem.

I am using a RHEL-compatible linux OS, and have ARM installed. (Which shows no problems at all.) Tor is set in client-only mode.

Please guide me on how to check Tor status from command-line, and where to look for errors to get my connection back.

Additionally, how can I determine if Tor is blocked by my ISP and whether if I need to use bridges? How can I set up bridges on torrc using command-line?

UPDATE: I noticed my server's time had gone out of sync. If you have a similar problem, make sure your machine's time is correct. Here's what I did.

  • 1
    Please include your tor logs. – cacahuatl Sep 20 '16 at 0:37
  • @canonizingironize I checked my logs, and turned out my server's time had gone out of sync. Did a ntpdate pool.ntp.org and now it works like a charm. No bridges required. – David Refoua Nov 11 '16 at 14:52
14

You can use curl to check https://check.torproject.org/:

curl --socks5 localhost:9050 --socks5-hostname localhost:9050 -s https://check.torproject.org/ | cat | grep -m 1 Congratulations | xargs

If everything goes well, the output will be:

Congratulations. This browser is configured to use Tor.

Getting no output (or an error) means somethings not working. However, check.torproject.org is prone to false negatives (see comments), so you might want to retry the command a few times to be sure.


Explanation:

  • --socks5 localhost:9050 tells curl to use our tor proxy
  • --socks5-hostname localhost:9050 forces domain resolution through tor too
  • -s silences curl's output
  • check.torproject.org a page on the tor project's site used to confirm connections
  • cat is used to fix the broken pipe.
  • grep -m 1 filters the output to just include the "Congratulations" line once.
  • xargs trims the whitespace from the beginning and end of the line.
  • 3
    You should either --socks5-hostname localhost:9050 or -x socks5h://127.0.0.1:9050/ to avoid DNS leaks. Also there will be false positives. – cacahuatl Nov 8 '16 at 5:09
  • 1
    What would cause the false positives? – Keith Nov 10 '16 at 3:41
  • 1
    Not all exits exit from their advertised IP addresses, the Tor Project probes each exit periodically but some of them change the IP they exit from semi-frequently. This means that the check.tpo site will think it's not a Tor IP address in a small number of cases and report that you aren't using Tor when infact you are. – cacahuatl Nov 10 '16 at 4:03
  • 1
    github.com/NullHypothesis/exitmap/blob/master/src/modules/… ExitMap has a module to check for these, I guess really they're false negatives, not false positives. False positives will happen if you are connecting from an exit or an IP that was used by an exit (maybe a VPN IP?) and are using a browser that is naively indistinguishable from Tor Browser. (e.g. user-agent string matches). – cacahuatl Nov 10 '16 at 4:08
  • 1
    OK, false negatives are not as bad. I'll mention them in my answer. The full curl response does complain "However, it does not appear to be Tor Browser." But at least we know that tor is proxying correctly. – Keith Nov 10 '16 at 13:20
0

Actually, using cURL and so-forth has a partial effect: you can tell that Tor is working in a manner of true/false. To troubleshoot the problem automatically you should use a pipe analyzer for it's logs, and then - for example - you'll be able to fix the issue with time automatically(i.e. enforce the launch of ntpdate)

  • Thanks for the additional answer, but in this case I was really interested in the true/false manner if Tor was working (e. g. directing traffic through itself) – David Refoua Nov 11 '16 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.