1
# -*- test-case-name: twisted.conch.test.test_tap -*-
2
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
3
# See LICENSE for details.
6
Support module for making SSH servers with twistd.
9
from twisted.conch import checkers, unix
10
from twisted.conch.openssh_compat import factory
11
from twisted.cred import portal
12
from twisted.python import usage
13
from twisted.application import strports
15
from twisted.cred import pamauth
21
class Options(usage.Options):
22
synopsis = "[-i <interface>] [-p <port>] [-d <dir>] "
23
longdesc = "Makes a Conch SSH server."
25
["interface", "i", "", "local interface to which we listen"],
26
["port", "p", "22", "Port on which to listen"],
27
["data", "d", "/etc", "directory to look for host keys in"],
28
["moduli", "", None, "directory to look for moduli in "
29
"(if different from --data)"]
31
zsh_actions = {"data" : "_dirs", "moduli" : "_dirs"}
34
def makeService(config):
35
t = factory.OpenSSHFactory()
36
t.portal = portal.Portal(unix.UnixSSHRealm())
37
t.portal.registerChecker(checkers.UNIXPasswordDatabase())
38
t.portal.registerChecker(checkers.SSHPublicKeyDatabase())
39
if pamauth is not None:
40
from twisted.cred.checkers import PluggableAuthenticationModulesChecker
41
t.portal.registerChecker(PluggableAuthenticationModulesChecker())
42
t.dataRoot = config['data']
43
t.moduliRoot = config['moduli'] or config['data']
45
if config['interface']:
47
port += ':interface='+config['interface']
48
return strports.service(port, t)