diff options
Diffstat (limited to 'login.py')
-rw-r--r-- | login.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/login.py b/login.py new file mode 100644 index 0000000..869f678 --- /dev/null +++ b/login.py @@ -0,0 +1,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() |