from twisted.cred import portal, checkers from twisted.conch import manhole, manhole_ssh def getManholeFactory(namespace, **passwords): def getManhole(_): return manhole.Manhole(namespace) realm = manhole_ssh.TerminalRealm() realm.chainedProtocolFactory.protocolFactory = getManhole p = portal.Portal(realm) p.registerChecker(checkers.InMemoryUsernamePasswordDatabaseDontUse(**passwords)) return manhole_ssh.ConchFactory(p) if __name__ == '__main__': from twisted.internet import reactor factory = getManholeFactory({'x': 'foo'}, user = 'pass') reactor.listenTCP(5022, factory) reactor.run()