# -*- test-case-name: twisted.conch.test.test_tap -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Support module for making SSH servers with twistd. """ from twisted.conch import unix from twisted.conch import checkers as conch_checkers from twisted.conch.openssh_compat import factory from twisted.cred import portal, strcred from twisted.python import usage from twisted.application import strports class Options(usage.Options, strcred.AuthOptionMixin): synopsis = "[-i <interface>] [-p <port>] [-d <dir>] " longdesc = ("Makes a Conch SSH server. If no authentication methods are " "specified, the default authentication methods are UNIX passwords " "and SSH public keys. If --auth options are " "passed, only the measures specified will be used.") optParameters = [ ["interface", "i", "", "local interface to which we listen"], ["port", "p", "tcp:22", "Port on which to listen"], ["data", "d", "/etc", "directory to look for host keys in"], ["moduli", "", None, "directory to look for moduli in " "(if different from --data)"] ] compData = usage.Completions( optActions={"data": usage.CompleteDirs(descr="data directory"), "moduli": usage.CompleteDirs(descr="moduli directory"), "interface": usage.CompleteNetInterfaces()} ) def __init__(self, *a, **kw): usage.Options.__init__(self, *a, **kw) # Call the default addCheckers (for backwards compatibility) that will # be used if no --auth option is provided - note that conch's # UNIXPasswordDatabase is used, instead of twisted.plugins.cred_unix's # checker super(Options, self).addChecker(conch_checkers.UNIXPasswordDatabase()) super(Options, self).addChecker(conch_checkers.SSHPublicKeyChecker( conch_checkers.UNIXAuthorizedKeysFiles())) self._usingDefaultAuth = True def addChecker(self, checker): """ Add the checker specified. If any checkers are added, the default checkers are automatically cleared and the only checkers will be the specified one(s). """ if self._usingDefaultAuth: self['credCheckers'] = [] self['credInterfaces'] = {} self._usingDefaultAuth = False super(Options, self).addChecker(checker) 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)
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
client | Folder | 0755 |
|
|
insults | Folder | 0755 |
|
|
openssh_compat | Folder | 0755 |
|
|
scripts | Folder | 0755 |
|
|
ssh | Folder | 0755 |
|
|
test | Folder | 0755 |
|
|
ui | Folder | 0755 |
|
|
__init__.py | File | 515 B | 0644 |
|
avatar.py | File | 1.4 KB | 0644 |
|
checkers.py | File | 19.28 KB | 0644 |
|
endpoints.py | File | 28.33 KB | 0644 |
|
error.py | File | 2.65 KB | 0644 |
|
interfaces.py | File | 12.76 KB | 0644 |
|
ls.py | File | 2.49 KB | 0644 |
|
manhole.py | File | 11.3 KB | 0644 |
|
manhole_ssh.py | File | 3.9 KB | 0644 |
|
manhole_tap.py | File | 5.24 KB | 0644 |
|
mixin.py | File | 1.34 KB | 0644 |
|
recvline.py | File | 11.25 KB | 0644 |
|
stdio.py | File | 2.71 KB | 0644 |
|
tap.py | File | 3.11 KB | 0644 |
|
telnet.py | File | 37.64 KB | 0644 |
|
ttymodes.py | File | 2.19 KB | 0644 |
|
unix.py | File | 15.91 KB | 0644 |
|