blob: 869f67806122295219583f07bb673695cc33ef08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
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()
|