from twisted.cred import portal, checkers from twisted.conch import manhole, manhole_ssh import hashlib def hash(username, netpass, localpass): return hashlib.sha1(netpass).hexdigest() def getManholeFactory(namespace, filename): def getManhole(_): return manhole.Manhole(namespace) realm = manhole_ssh.TerminalRealm() realm.chainedProtocolFactory.protocolFactory = getManhole p = portal.Portal(realm) p.registerChecker(checkers.FilePasswordDB(filename, hash = hash)) return manhole_ssh.ConchFactory(p) if __name__ == '__main__': from twisted.internet import reactor import os factory = getManholeFactory({'x': 'foo'}, os.path.expanduser('~/.fot.users')) reactor.listenTCP(5022, factory) reactor.run()