run torpy from the commandline:
generate a password for accessing tor remotely, and append it to your torrc #+BEGIN_SRC shell % /usr/sbin/tor --hash-password "password" Oct 23 23:39:44.561 [notice] Tor v0.2.3.22-rc (git-4a0c70a817797420) running on Linux. Oct 23 23:39:44.561 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning Oct 23 23:39:44.564 [notice] This version of OpenSSL has a known-good EVP counter-mode implementation. Using it. 16:1387221FFADC246D60BEAA58274647717AA12A2ACE268F7AF0D5BF271A
% sudo printf "\nCookieAuthentication 0\nHashedControlPassword 16:1387221FFADC246D60BEAA58274647717AA12A2ACE268F7AF0D5BF271A\n" >>/etc/tor/torrc #+END_SRC
#+BEGIN_SRC shell git submodule init git submodule update
virtualenv env source env/bin/activate pip install pytorctl/ #note the / at the end!
echo 'passphrase="password"' >config.py #+END_SRC
usage:
#+BEGIN_SRC shell torpy list torpy status torpy start host:port torpy stop " #+END_SRC
or use it from python:
#+BEGIN_SRC python tp=Torpy(passphrase)
tp.list()
print "running" if tp.status("test_service") else "not running"
tp.start("test_service","localhost:80","80")
print "running" if tp.status("test_service") else "not running"
tp.stop("test_service")
tp.close() #+END_SRC
warning if you start a new onion service using start, the full path must be readable, writable, and executable (o+rwx) by the user running tor.