当前位置: 首页>>代码示例>>Python>>正文


Python factory.SSHFactory方法代码示例

本文整理汇总了Python中twisted.conch.ssh.factory.SSHFactory方法的典型用法代码示例。如果您正苦于以下问题:Python factory.SSHFactory方法的具体用法?Python factory.SSHFactory怎么用?Python factory.SSHFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.conch.ssh.factory的用法示例。


在下文中一共展示了factory.SSHFactory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testMultipleFactories

# 需要导入模块: from twisted.conch.ssh import factory [as 别名]
# 或者: from twisted.conch.ssh.factory import SSHFactory [as 别名]
def testMultipleFactories(self):
        f1 = factory.SSHFactory()
        f2 = factory.SSHFactory()
        gpk = lambda: {'ssh-rsa' : "don't use"}
        f1.getPrimes = lambda: None
        f2.getPrimes = lambda: {1:(2,3)}
        f1.getPublicKeys = f2.getPublicKeys = gpk
        f1.getPrivateKeys = f2.getPrivateKeys = gpk
        f1.startFactory()
        f2.startFactory()
        p1 = f1.buildProtocol(None)
        p2 = f2.buildProtocol(None)
        self.failIf('diffie-hellman-group-exchange-sha1' in p1.supportedKeyExchanges,
                p1.supportedKeyExchanges)
        self.failUnless('diffie-hellman-group-exchange-sha1' in p2.supportedKeyExchanges,
                p2.supportedKeyExchanges) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:18,代码来源:test_ssh.py

示例2: hook_to_reactor

# 需要导入模块: from twisted.conch.ssh import factory [as 别名]
# 或者: from twisted.conch.ssh.factory import SSHFactory [as 别名]
def hook_to_reactor(self, reactor):
        ssh_factory = factory.SSHFactory()
        ssh_factory.portal = portal.Portal(SSHDemoRealm(self.switch_core))
        if not self.users:
            self.users = {'root': b'root'}
        ssh_factory.portal.registerChecker(
            checkers.InMemoryUsernamePasswordDatabaseDontUse(**self.users))

        host_public_key, host_private_key = getRSAKeys()
        ssh_factory.publicKeys = {
            b'ssh-rsa': keys.Key.fromString(data=host_public_key.encode())}
        ssh_factory.privateKeys = {
            b'ssh-rsa': keys.Key.fromString(data=host_private_key.encode())}

        lport = reactor.listenTCP(port=self.port, factory=ssh_factory, interface=self.ip)
        logging.info(lport)
        logging.info(
            "%s (SSH): Registered on %s tcp/%s" % (self.switch_core.switch_configuration.name, self.ip, self.port))
        return lport 
开发者ID:internap,项目名称:fake-switches,代码行数:21,代码来源:ssh_service.py

示例3: start_ssh_server

# 需要导入模块: from twisted.conch.ssh import factory [as 别名]
# 或者: from twisted.conch.ssh.factory import SSHFactory [as 别名]
def start_ssh_server(self):
        try:
            log.debug('starting', port=self.netconf_port)
            self.set_capabilities()
            self.portal = self.setup_secure_access()
            self.connector = reactor.listenTCP(self.netconf_port, self)
            log.debug('started', port=self.netconf_port)
            self.d_stopped = Deferred()
            self.d_stopped.callback(self.stop)
            yield self.d_stopped
        except Exception as e:
            log.error('netconf-server-not-started', port=self.netconf_port,
                      exception=repr(e))

    # Methods from SSHFactory
    # 
开发者ID:opencord,项目名称:voltha,代码行数:18,代码来源:nc_server.py

示例4: getService

# 需要导入模块: from twisted.conch.ssh import factory [as 别名]
# 或者: from twisted.conch.ssh.factory import SSHFactory [as 别名]
def getService(self, trans, name):
            return factory.SSHFactory.getService(self, trans, name) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:4,代码来源:test_ssh.py

示例5: makeSSHFactory

# 需要导入模块: from twisted.conch.ssh import factory [as 别名]
# 或者: from twisted.conch.ssh.factory import SSHFactory [as 别名]
def makeSSHFactory(self, primes=None):
        sshFactory = factory.SSHFactory()
        gpk = lambda: {'ssh-rsa' : keys.Key(None)}
        sshFactory.getPrimes = lambda: primes
        sshFactory.getPublicKeys = sshFactory.getPrivateKeys = gpk
        sshFactory.startFactory()
        return sshFactory 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_ssh.py


注:本文中的twisted.conch.ssh.factory.SSHFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。