本文整理汇总了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)
示例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
示例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
#
示例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)
示例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