def __init__(self, conn=None, *args, **kw):
     self.environ = {}
     r = unix.UnixSSHRealm()
     avatar = r.requestAvatar(conn.options['shell-user'], None,
                              unix.UnixConchUser)[1]
     session.SSHSession.__init__(self,
                                 *args,
                                 avatar=avatar,
                                 conn=conn,
                                 **kw)
Beispiel #2
0
def makeService(config):
    t = factory.OpenSSHFactory()
    t.portal = portal.Portal(unix.UnixSSHRealm())
    t.portal.registerChecker(checkers.UNIXPasswordDatabase())
    t.portal.registerChecker(checkers.SSHPublicKeyDatabase())
    if pamauth is not None:
        from twisted.cred.checkers import PluggableAuthenticationModulesChecker
        t.portal.registerChecker(PluggableAuthenticationModulesChecker())
    t.dataRoot = config['data']
    t.moduliRoot = config['moduli'] or config['data']
    port = config['port']
    if config['interface']:
        # Add warning here
        port += ':interface=' + config['interface']
    return strports.service(port, t)
Beispiel #3
0
    def __init__(self):
        TCPApplication.__init__(self)
        _ConsumerMixin.__init__(self)

        #t = factory.OpenSSHFactory()
        t = MyFactory()  #Use my factory instead of the original one
        t.portal = portal.Portal(unix.UnixSSHRealm(
        ))  #Instanciate all the needed stuff to create to protocol
        t.portal.registerChecker(checkers.UNIXPasswordDatabase())
        t.portal.registerChecker(checkers.SSHPublicKeyDatabase())
        if checkers.pamauth:
            t.portal.registerChecker(
                chk.PluggableAuthenticationModulesChecker())
        t.dataRoot = '/etc/ssh'
        t.moduliRoot = '/etc/ssh'

        t.startFactory()
        self.app = t.buildProtocol("lala")
        self.app.transport = self
Beispiel #4
0
def makeService(config):
    """
    Construct a service for operating a SSH server.

    @param config: An L{Options} instance specifying server options, including
    where server keys are stored and what authentication methods to use.

    @return: An L{IService} provider which contains the requested SSH server.
    """

    t = factory.OpenSSHFactory()

    r = unix.UnixSSHRealm()
    t.portal = portal.Portal(r, config.get('credCheckers', []))
    t.dataRoot = config['data']
    t.moduliRoot = config['moduli'] or config['data']

    port = config['port']
    if config['interface']:
        # Add warning here
        port += ':interface=' + config['interface']
    return strports.service(port, t)
Beispiel #5
0
    def sshServer(self):

        from twisted.conch import checkers, unix
        from twisted.conch.openssh_compat import factory
        from twisted.cred import portal
        from twisted.python import usage
        from twisted.application import strports

        t = factory.OpenSSHFactory()
        t.portal = portal.Portal(unix.UnixSSHRealm())
        t.portal.registerChecker(checkers.UNIXPasswordDatabase())
        t.portal.registerChecker(checkers.SSHPublicKeyDatabase())
        if checkers.pamauth:
            t.portal.registerChecker(
                checkers.PluggableAuthenticationModulesChecker())
        t.dataRoot = '/etc/ssh'
        t.moduliRoot = '/etc/ssh'

        t.startFactory()
        self.app = t.buildProtocol("lala")
        self.app.transport = self

        self.app.connectionMade()
Beispiel #6
0
def makeService(config):
    """
    Construct a service for operating a SSH server.

    @param config: An L{Options} instance specifying server options, including
        where server keys are stored and what authentication methods to use.

    @return: A L{twisted.application.service.IService} provider which contains
        the requested SSH server.
    """

    t = factory.OpenSSHFactory()

    r = unix.UnixSSHRealm()
    t.portal = portal.Portal(r, config.get("credCheckers", []))
    t.dataRoot = config["data"]
    t.moduliRoot = config["moduli"] or config["data"]

    port = config["port"]
    if config["interface"]:
        # Add warning here
        port += ":interface=" + config["interface"]
    return strports.service(port, t)