示例#1
0
    def secureConnection(self):
        """
        Create and return a new SSH connection which has been secured and on
        which authentication has already happened.

        @return: A L{Deferred} which fires with the ready-to-use connection or
            with a failure if something prevents the connection from being
            setup, secured, or authenticated.
        """
        factory = Factory()
        factory.protocol = _CommandTransport
        factory.hostname = self.hostname
        factory.username = self.username
        factory.keys = self.keys
        factory.password = self.password
        factory.agentEndpoint = self.agentEndpoint
        factory.knownHosts = self.knownHosts
        factory.command = self.command
        factory.ui = self.ui
        factory.creator = self

        factory.connectionReady = Deferred()

        sshClient = TCP4ClientEndpoint(self.reactor, self.hostname, self.port)

        d = sshClient.connect(factory)
        d.addCallback(lambda ignored: factory.connectionReady)
        return d
示例#2
0
    def connect(self, protocolFactory):
        factory = Factory()
        factory.protocol = _CommandTransport
        factory.command = self._command
        factory.commandProtocolFactory = protocolFactory
        factory.commandConnected = Deferred()

        d = self._sshServer.connect(factory)
        d.addErrback(factory.commandConnected.errback)

        return factory.commandConnected
示例#3
0
    def connect(self, protocolFactory):
        factory = Factory()
        factory.protocol = _CommandTransport
        factory.command = self._command
        factory.commandProtocolFactory = protocolFactory
        factory.commandConnected = Deferred()

        d = self._sshServer.connect(factory)
        d.addErrback(factory.commandConnected.errback)

        return factory.commandConnected