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