[tor-dev] authentication questions on Tor controller

jiang song luolisongjiang at gmail.com
Thu Nov 8 17:47:34 UTC 2012


I just start to use tor controller,  I notice the mannual says:

 pass Tor the "--CookieAuthentication 1" option when you start it.
Tor will create a file in its data directory
 called "control_auth_cookie".  All your controller needs to do is to
pass the contents of this file to authenticate()
 when it connects to Tor.


 there are two kinds of Tor, one is installed and can be run by command
"tor"
the other is Tor Browser Bundle,

1) with command "tor", when it establishes, if I run example.py
the result is
           "Connection refused. Is the ControlPort enabled?"

I tried command:  "tor --CookieAuthentication 1"  to start Tor,
but I can't find the so called data directory, and the running information
says:
                        Could not open "/etc/tor/torrc": Permission denied

2) with TBB, after I started TBB, if I run example.py,
it seems it can connect to ControlPort, but it prompts for a password
there is a Data directory in TBB, but I can't find the  so called "
control_auth_cookie"
file, so when I run TBB, how can I pass "--CookieAuthentication 1" to tor?


example.py :

import time
import TorCtl

class BandwidthListener(TorCtl.PostEventListener):
  def __init__(self):
    TorCtl.PostEventListener.__init__(self)

  def bandwidth_event(self, event):
    print "tor read %i bytes and wrote %i bytes" % (event.read,
event.written)

# constructs a listener that prints BW events
myListener = BandwidthListener()

# initiates a TorCtl connection, returning None if it was unsuccessful
conn = TorCtl.connect()

if conn:
  # tells tor to send us BW events
  conn.set_events(["BW"])

  # attaches the listener so it'll receive BW events
  conn.add_event_listener(myListener)

  # run until we get a keyboard interrupt
  try:
    while True:
      time.sleep(10)
  except KeyboardInterrupt: pass
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20121108/d40bca88/attachment.html>


More information about the tor-dev mailing list