':param FilePath base_path: The path beneath which all of the temporary
SSH server-related files will be created.  An ``ssh`` directory
will be created as a child of this directory to hold the key pair
that is generated.  An ``sshd`` directory will also be created here
to hold the generated host key.  A ``home`` directory is also
created here and used as the home directory for shell logins to the
server.'

def __init__(self, base_path):

    self.home = base_path.child('home')
    self.home.makedirs()
    ssh_path = base_path.child('ssh')
    ssh_path.makedirs()
    self.key_path = ssh_path.child('key')
    key = generate_ssh_key(self.key_path)
    sshd_path = base_path.child('sshd')
    sshd_path.makedirs()
    self.host_key_path = sshd_path.child('ssh_host_key')
    generate_ssh_key(self.host_key_path)
    factory = OpenSSHFactory()
    realm = _UnixSSHRealm(self.home)
    checker = _InMemoryPublicKeyChecker(public_key=key.public())
    factory.portal = Portal(realm, [checker])
    factory.dataRoot = sshd_path.path
    factory.moduliRoot = '/etc/ssh'
    self._port = reactor.listenTCP(0, factory, interface='127.0.0.1')
    self.ip = IPAddress(self._port.getHost().host)
    self.port = self._port.getHost().port
