Class NettySshTtyBootstrap

java.lang.Object
org.aesh.terminal.ssh.netty.NettySshTtyBootstrap

public class NettySshTtyBootstrap extends Object
Bootstrap class for starting an SSH TTY server using Netty.
Author:
Julien Viet
  • Constructor Details

    • NettySshTtyBootstrap

      public NettySshTtyBootstrap()
      Creates a new NettySshTtyBootstrap with default settings. Defaults to localhost:5000 with UTF-8 charset.
  • Method Details

    • getHost

      public String getHost()
      Returns the host address the server will bind to.
      Returns:
      the host address
    • setHost

      public NettySshTtyBootstrap setHost(String host)
      Sets the host address for the SSH server to bind to.
      Parameters:
      host - the host address
      Returns:
      this bootstrap for method chaining
    • getPort

      public int getPort()
      Returns the port the server will listen on.
      Returns:
      the port number
    • setPort

      public NettySshTtyBootstrap setPort(int port)
      Sets the port for the SSH server to listen on.
      Parameters:
      port - the port number
      Returns:
      this bootstrap for method chaining
    • setPasswordAuthenticator

      public NettySshTtyBootstrap setPasswordAuthenticator(org.apache.sshd.server.auth.password.PasswordAuthenticator passwordAuthenticator)
      Sets the password authenticator for SSH connections.
      Parameters:
      passwordAuthenticator - the authenticator to validate username/password
      Returns:
      this bootstrap for method chaining
    • setPublicKeyAuthenticator

      public NettySshTtyBootstrap setPublicKeyAuthenticator(org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator publicKeyAuthenticator)
      Sets the public key authenticator for SSH connections.
      Parameters:
      publicKeyAuthenticator - the authenticator to validate public keys
      Returns:
      this bootstrap for method chaining
    • start

      public CompletableFuture<Void> start(Consumer<Connection> handler) throws Exception
      Starts the SSH server asynchronously.
      Parameters:
      handler - the connection handler for new SSH sessions
      Returns:
      a CompletableFuture that completes when the server has started
      Throws:
      Exception - if the server fails to start
    • getKeyPairProvider

      public org.apache.sshd.common.keyprovider.KeyPairProvider getKeyPairProvider()
      Returns the key pair provider used for SSH host keys.
      Returns:
      the key pair provider
    • setKeyPairProvider

      public NettySshTtyBootstrap setKeyPairProvider(org.apache.sshd.common.keyprovider.KeyPairProvider keyPairProvider)
      Sets the key pair provider for SSH host keys.
      Parameters:
      keyPairProvider - the key pair provider
      Returns:
      this bootstrap for method chaining
    • getCharset

      public Charset getCharset()
      Returns the character set used for encoding/decoding.
      Returns:
      the charset
    • setCharset

      public void setCharset(Charset charset)
      Sets the character set for encoding/decoding.
      Parameters:
      charset - the charset to use
    • start

      public void start(Consumer<Connection> factory, Consumer<Throwable> doneHandler)
      Starts the SSH server with a callback for completion notification.
      Parameters:
      factory - the connection handler factory for new SSH sessions
      doneHandler - callback invoked with null on success, or the exception on failure
    • stop

      Stops the SSH server asynchronously.
      Returns:
      a CompletableFuture that completes when the server has stopped
      Throws:
      InterruptedException - if interrupted while stopping
    • stop

      public void stop(Consumer<Throwable> doneHandler)
      Stops the SSH server with a callback for completion notification.
      Parameters:
      doneHandler - callback invoked with null on success, or the exception on failure