def start()

in pekko-connectors-sample-rotate-logs-to-ftp/src/main/scala/playground/SftpServerEmbedded.scala [35:56]


  def start(fileSystem: FileSystem, port: Int): Unit = {
    sshd = SshServer.setUpDefaultServer()
    sshd.setHost(hostname)
    sshd.setPort(port)
    sshd.setKeyPairProvider(new FileKeyPairProvider(Paths.get(keyPairProviderFile)))
    sshd.setSubsystemFactories(util.Arrays.asList(new SftpSubsystemFactory))
    sshd.setCommandFactory(new ScpCommandFactory())
    val passwordAuthenticator = new PasswordAuthenticator() {
      override def authenticate(username: String, password: String, session: ServerSession): Boolean =
        username != null && username == password
    }
    sshd.setPasswordAuthenticator(passwordAuthenticator)
    val publicKeyAuthenticator = new PublickeyAuthenticator() {
      override def authenticate(username: String, key: PublicKey, session: ServerSession): Boolean = true
    }
    sshd.setPublickeyAuthenticator(publicKeyAuthenticator)

    val home: Path = fileSystem.getPath(FtpRootDir)
    sshd.setFileSystemFactory(new VirtualFileSystemFactory(home))
    sshd.start()
    if (!Files.exists(home)) Files.createDirectories(home)
  }