summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--login.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/login.py b/login.py
index 6c95e56..a39ffd3 100644
--- a/login.py
+++ b/login.py
@@ -1,6 +1,9 @@
from twisted.cred import portal, checkers
from twisted.conch import manhole, manhole_ssh
+from twisted.conch.ssh import keys
+from twisted.python import filepath
import hashlib
+import os
def hash(username, netpass, localpass):
return hashlib.sha1(netpass).hexdigest()
@@ -15,11 +18,14 @@ def getManholeFactory(namespace, filename):
p = portal.Portal(realm)
p.registerChecker(checkers.FilePasswordDB(filename, hash = hash))
- return manhole_ssh.ConchFactory(p)
+ factory = manhole_ssh.ConchFactory(p)
+ ssh_key = keys._getPersistentRSAKey(filepath.FilePath(os.path.expanduser('~/.fot.ssh')).child('id_rsa'), 2048)
+ factory.publicKeys[b'ssh-rsa'] = ssh_key
+ factory.privateKeys[b'ssh-rsa'] = ssh_key
+ return factory
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()