问题描述
我尝试了此示例:
import getpass
import sys
import stem
import stem.connection
from stem.control import Controller
if __name__ == '__main__':
try:
controller = Controller.from_port()
except stem.SocketError as exc:
print("Unable to connect to tor on port 9051: %s" % exc)
sys.exit(1)
try:
controller.authenticate()
except stem.connection.MissingPassword:
pw = getpass.getpass("Controller password: ")
try:
controller.authenticate(password = pw)
except stem.connection.PasswordAuthFailed:
print("Unable to authenticate, password is incorrect")
sys.exit(1)
except stem.connection.AuthenticationFailure as exc:
print("Unable to authenticate: %s" % exc)
sys.exit(1)
print("Tor is running version %s" % controller.get_version())
controller.close()
在Stem上按
检查Tor的控制器如何工作.但这给了我错误:
on Stem to check how Tor's controller works. But its giving me the error:
我已经在/etc/tor/内的torrc文件中将ControlPort设置为9051,但仍然遇到相同的错误.谁能帮忙吗?(我在VirtualBox上使用Ubuntu 14.04)
I have set the ControlPort to 9051 in the torrc file inside /etc/tor/ but am still getting the same error. Could anyone please help?(I am using Ubuntu 14.04 on VirtualBox)
在终端上也运行tor --controlport 9051会给出错误:
Also running tor --controlport 9051 on the terminal gives the error:
Feb 29 17:50:17.842 [notice] Tor v0.2.4.27 (git-412e3f7dc9c6c01a) running on Linux with Libevent 2.0.21-stable and OpenSSL 1.0.1f.
Feb 29 17:50:17.842 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Feb 29 17:50:17.842 [notice] Read configuration file "/etc/tor/torrc".
Feb 29 17:50:17.854 [notice] Opening Socks listener on 127.0.0.1:9050
Feb 29 17:50:17.854 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Feb 29 17:50:17.854 [notice] Opening Control listener on 127.0.0.1:9051
Feb 29 17:50:17.854 [notice] Closing partially-constructed Control listener on 127.0.0.1:9051
Feb 29 17:50:17.854 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Feb 29 17:50:17.854 [err] Reading config failed--see warnings above.
但是当我跑步
没有Tor运行的实例.我尝试了命令sudo killall tor
,然后用sudo /etc/init.d/tor status
对其进行了检查,现在它给出了身份验证错误:
there is no instance of tor running.EDIT 2: I tried the command sudo killall tor
and then checked it with sudo /etc/init.d/tor status
and now its giving an authentication error:
File "circuitPage.py", line 82, in printCircuitInfo
controller.authenticate()
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 991, in authenticate
stem.connection.authenticate(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/stem/connection.py", line 520, in authenticate
raise AuthenticationFailure('socket connection failed (%s)' % exc)
stem.connection.AuthenticationFailure: socket connection failed ([Errno 111] Connection refused)
推荐答案
在/etc/tor/torrc
配置文件中找到ControlPort 9051
,然后取消注释该行.
然后通过以下方式重置tor:sudo service tor restart
现在您可以连接到端口9051
find ControlPort 9051
in /etc/tor/torrc
config file then uncomment the line.
then reset tor by:sudo service tor restart
now you can connect to port 9051
这篇关于Stem正在给出“无法连接到端口9051".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!