Class SimpleConsoleSshServer.Builder

java.lang.Object
org.dellroad.jct.ssh.simple.SimpleConsoleSshServer.Builder
Enclosing class:
SimpleConsoleSshServer

public static final class SimpleConsoleSshServer.Builder extends Object
Builder for new SimpleConsoleSshServer instances.

The following properties are required: console, authenticator, and host key.

  • Method Details

    • exec

      Configure the Exec that successful incoming execute connections should connect to.

      This property or #shell shell() is required.

      Parameters:
      exec - target exec
      Returns:
      this instance
    • shell

      public SimpleConsoleSshServer.Builder shell(Shell shell)
      Configure the Shell that successful incoming shell connections should connect to.

      This property or #shell shell() is required.

      Parameters:
      shell - target shell
      Returns:
      this instance
    • loopbackOnly

      public SimpleConsoleSshServer.Builder loopbackOnly(boolean loopbackOnly)
      Configure whether to listen for new connections only on the loopback interface, or on all interfaces.

      Default is to listen only on the loopback interface.

      Parameters:
      loopbackOnly - true to listen for new connections only on the loopback interface
      Returns:
      this instance
    • listenPort

      public SimpleConsoleSshServer.Builder listenPort(int port)
      Configure the TCP port on which to listen for new connections.

      Default is SshConstants.DEFAULT_PORT.

      Parameters:
      port - TCP port to listen on
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if port is invalid
    • authenticator

      public SimpleConsoleSshServer.Builder authenticator(org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator authenticator)
      Configure the public key authenticator that authenticates new incoming connections.
      Parameters:
      authenticator - public key authenticator
      Returns:
      this instance
    • authorizedKeys

      public SimpleConsoleSshServer.Builder authorizedKeys(String authorizedKeys) throws IOException, GeneralSecurityException
      Read authorized users' public keys from a String.
      Parameters:
      authorizedKeys - the content of an openssh authorized_keys file
      Returns:
      this instance
      Throws:
      IOException - if authorizedKeys contains invalid content
      GeneralSecurityException - if public key data could not be parsed
      IllegalArgumentException - if authorizedKeys is null
    • authorizedKeys

      public SimpleConsoleSshServer.Builder authorizedKeys(InputStream authorizedKeys) throws IOException, GeneralSecurityException
      Read authorized users' public keys from an InputStream.

      The given stream will not be closed by this method.

      Parameters:
      authorizedKeys - input from an openssh authorized_keys file
      Returns:
      this instance
      Throws:
      IOException - if authorizedKeys contains invalid content
      GeneralSecurityException - if public key data could not be parsed
      IllegalArgumentException - if authorizedKeys is null
    • authorizedKeys

      public SimpleConsoleSshServer.Builder authorizedKeys(Path authorizedKeys)
      Configurea authorized users' public keys to be read from a file at connection time.
      Parameters:
      authorizedKeys - openssh authorized_keys file
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if authorizedKeys is null
    • hostKeyProvider

      public SimpleConsoleSshServer.Builder hostKeyProvider(org.apache.sshd.common.keyprovider.KeyPairProvider hostKeyProvider)
      Configure the host key provider.
      Parameters:
      hostKeyProvider - public key provider for host keys
      Returns:
      this instance
    • hostKey

      public SimpleConsoleSshServer.Builder hostKey(Path hostKey)
      Configure the host key to be read from a file at connection time.
      Parameters:
      hostKey - openssh host key file
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if hostKey is null
    • hostKey

      public SimpleConsoleSshServer.Builder hostKey(ClassLoader loader, String resource)
      Configure the host key to be read from a classpath resource at connection time.
      Parameters:
      loader - class loader
      resource - classpath resource
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if either parameter is null
    • build

      public SimpleConsoleSshServer build()
      Build a new SimpleConsoleSshServer based on this instance.
      Returns:
      new server configured by this instance
      Throws:
      IllegalArgumentException - if this builder is incompletely configured