I tried connecting to tor in TBB 3.5.1, OS X 10.8.5 using telnet localhost 9151 but since CookieAuthentication is set it requires authentication.

From the manual

CookieAuthentication 0|1 If this option is set to 1, allow connections on the control port when the connecting process knows the contents of a file named "control_auth_cookie", which Tor will create in its data directory. This authentication method should only be used on systems with good filesystem security. (Default: 0)

I checked RFCs and other sources for TELNET/telnet but I couldn't find any information on this matter.

How can I authenticate using the cookie?

1 Answer 1

  1. Locate the file control_auth_cookie
  2. Enter hexdump -e '32/1 "%02x""\n"' $COOKIEFILE where $COOKIEFILE is the location of the file from step 1.
  3. Copy the output
  4. Open a shell and enter telnet 9151. If you can't get a connection check if Tor listens on that port. Other versions listens on port 9050.
  5. When you see a prompt enter AUTHENTICATE $OUTPUTFROM2 where $OUTPUTFROM2 is the output you copied from step 2.
  6. Tor prints 250 OK and you're done.

If you like to put the steps above in a program, I'd suggest a shell script plus expect. In the answer to 'New tor bundle how to change identity programmatically?' I described how to do it for NEWNYM. You just need to insert the line send -- "getinfo circuit-status" at the correct line.

  • Great, it works. Before accepting it, how would you script the whole thing to just get the fingerprint of the exit relay node with getinfo circuit-status? S. tor.stackexchange.com/questions/1422/…
    – 1.61803
    Feb 4, 2014 at 20:46
  • I checked getinfo info/names but there's no direct way to get the fingerprint of the exit. Do you know how to get and parse it in expect_out?
    – 1.61803
    Feb 8, 2014 at 14:51
  • 1
    Hi Jens, thanks! This answer inspired me to add a FAQ entry discussing each of tor's connection and authentication scenarios: stem.torproject.org/…
    – Damian
    Mar 22, 2014 at 19:19

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.