Example #1
0
    def closed(self):
        pass


from twisted.python import components
components.registerAdapter(ExampleSession, ExampleAvatar, session.ISession)


class ExampleFactory(factory.SSHFactory):
    publicKeys = {'ssh-rsa': keys.Key.fromString(data=publicKey)}
    privateKeys = {'ssh-rsa': keys.Key.fromString(data=privateKey)}
    services = {
        'ssh-userauth': userauth.SSHUserAuthServer,
        'ssh-connection': connection.SSHConnection
    }


portal = portal.Portal(ExampleRealm())
passwdDB = InMemoryUsernamePasswordDatabaseDontUse()
passwdDB.addUser('user', 'password')
sshDB = SSHPublicKeyChecker(
    InMemoryKeyMapping({'user': [keys.Key.fromString(data=publicKey)]}))
portal.registerChecker(passwdDB)
portal.registerChecker(sshDB)
ExampleFactory.portal = portal

if __name__ == '__main__':
    reactor.listenTCP(5022, ExampleFactory())
    reactor.run()
Example #2
0
    def closed(self):
        pass

from twisted.python import components
components.registerAdapter(ExampleSession, ExampleAvatar, session.ISession)

class ExampleFactory(factory.SSHFactory):
    publicKeys = {
        'ssh-rsa': keys.Key.fromString(data=publicKey)
    }
    privateKeys = {
        'ssh-rsa': keys.Key.fromString(data=privateKey)
    }
    services = {
        'ssh-userauth': userauth.SSHUserAuthServer,
        'ssh-connection': connection.SSHConnection
    }


portal = portal.Portal(ExampleRealm())
passwdDB = InMemoryUsernamePasswordDatabaseDontUse()
passwdDB.addUser('pi', 'raspberry')
sshDB = SSHPublicKeyChecker(InMemoryKeyMapping(
    {'user': [keys.Key.fromString(data=publicKey)]}))
portal.registerChecker(passwdDB)
portal.registerChecker(sshDB)
ExampleFactory.portal = portal

if __name__ == '__main__':
    reactor.listenTCP(5022, ExampleFactory())
    reactor.run()
Example #3
0
    def eofReceived(self):
        pass

    def closed(self):
        pass


from twisted.python import components

components.registerAdapter(ExampleSession, ExampleAvatar, session.ISession)


class ExampleFactory(factory.SSHFactory):
    publicKeys = {"ssh-rsa": keys.Key.fromString(data=publicKey)}
    privateKeys = {"ssh-rsa": keys.Key.fromString(data=privateKey)}
    services = {"ssh-userauth": userauth.SSHUserAuthServer, "ssh-connection": connection.SSHConnection}


portal = portal.Portal(ExampleRealm())
passwdDB = InMemoryUsernamePasswordDatabaseDontUse()
passwdDB.addUser("user", "password")
sshDB = SSHPublicKeyChecker(InMemoryKeyMapping({"user": [keys.Key.fromString(data=publicKey)]}))
portal.registerChecker(passwdDB)
portal.registerChecker(sshDB)
ExampleFactory.portal = portal

if __name__ == "__main__":
    reactor.listenTCP(5022, ExampleFactory())
    reactor.run()