o bv @sjdZddlmZddlmZmZddlmZddl m Z m Z ddl m Z Gddde je jZd d Zd S) z4 Support module for making SSH servers with twistd. )strports)checkersunix)factory)portalstrcred)usagecsteZdZdZdZgdgdgdgdgZejejddejd de d d Z fd d Z fddZ Z S)Optionsz([-i ] [-p ] [-d ] zMakes 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.) interfaceiz"local interface to which we listen)portpztcp:22zPort on which to listen)datadz/etcz"directory to look for host keys in)modulir Nz:directory to look for moduli in (if different from --data)zdata directory)descrzmoduli directory)rrr ) optActionscsJtjj|g|Ri|tttttd|_ dS)NT) rr __init__super addCheckerconch_checkersUNIXPasswordDatabaseSSHPublicKeyCheckerUNIXAuthorizedKeysFiles_usingDefaultAuth)selfakw __class__3/usr/lib/python3/dist-packages/twisted/conch/tap.pyr+s   zOptions.__init__cs,|jrg|d<i|d<d|_t|dS)z 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). credCheckerscredInterfacesFN)rrr)rcheckerrr!r"r8s zOptions.addChecker)__name__ __module__ __qualname__synopsislongdesc optParametersr Completions CompleteDirsCompleteNetInterfacescompDatarr __classcell__r!r!rr"r s"    r cCsnt}t}t||dg|_|d|_|dp|d|_|d}|dr1|d|d7}t ||S)aH 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. r#rrr r z :interface=) rOpenSSHFactoryr UnixSSHRealmrPortalgetdataRoot moduliRootrservice)configtrr r!r!r" makeServiceEs   r;N)__doc__twisted.applicationr twisted.conchrrrtwisted.conch.openssh_compatr twisted.credrrtwisted.pythonrr AuthOptionMixinr;r!r!r!r"s    5