小编Can*_*lor的帖子

twisted.internet.error.ConnectionRefusedError:111:拒绝连接

我遇到以下问题: -

失败:twisted.internet.error.ConnectionRefusedError:连接被另一方拒绝:111:连接被拒绝.

我注意到客户端从不要求我输入密码.我是从PyCharm里面运行的.

谁能指出我正确的方向?

我的客户代码是: -

#!/usr/bin/env python

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

from twisted.conch.ssh import transport, userauth, connection, common, keys, channel
from twisted.internet import defer, protocol, reactor
from twisted.python import log
import struct, sys, getpass, os

USER = 'user'
HOST = 'localhost'

class SimpleTransport(transport.SSHClientTransport):
    def verifyHostKey(self, hostKey, fingerprint):
        print 'host key fingerprint: %s' % fingerprint
        return defer.succeed(1) 

    def connectionSecure(self):
        self.requestService(
            SimpleUserAuth(USER,
                SimpleConnection()))

class SimpleUserAuth(userauth.SSHUserAuthClient):
    def getPassword(self):
        return defer.succeed(getpass.getpass("password" % (USER, HOST)))

    def …
Run Code Online (Sandbox Code Playgroud)

twisted pycharm python-2.7

5
推荐指数
0
解决办法
2960
查看次数

标签 统计

pycharm ×1

python-2.7 ×1

twisted ×1