Class NettySshTtyBootstrap
java.lang.Object
org.aesh.terminal.ssh.netty.NettySshTtyBootstrap
Bootstrap class for starting an SSH TTY server using Netty.
- Author:
- Julien Viet
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new NettySshTtyBootstrap with default settings. -
Method Summary
Modifier and TypeMethodDescriptionReturns the character set used for encoding/decoding.getHost()Returns the host address the server will bind to.org.apache.sshd.common.keyprovider.KeyPairProviderReturns the key pair provider used for SSH host keys.intgetPort()Returns the port the server will listen on.voidsetCharset(Charset charset) Sets the character set for encoding/decoding.Sets the host address for the SSH server to bind to.setKeyPairProvider(org.apache.sshd.common.keyprovider.KeyPairProvider keyPairProvider) Sets the key pair provider for SSH host keys.setPasswordAuthenticator(org.apache.sshd.server.auth.password.PasswordAuthenticator passwordAuthenticator) Sets the password authenticator for SSH connections.setPort(int port) Sets the port for the SSH server to listen on.setPublicKeyAuthenticator(org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator publicKeyAuthenticator) Sets the public key authenticator for SSH connections.start(Consumer<Connection> handler) Starts the SSH server asynchronously.voidstart(Consumer<Connection> factory, Consumer<Throwable> doneHandler) Starts the SSH server with a callback for completion notification.stop()Stops the SSH server asynchronously.voidStops the SSH server with a callback for completion notification.
-
Constructor Details
-
NettySshTtyBootstrap
public NettySshTtyBootstrap()Creates a new NettySshTtyBootstrap with default settings. Defaults to localhost:5000 with UTF-8 charset.
-
-
Method Details
-
getHost
-
setHost
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
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
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
Returns the character set used for encoding/decoding.- Returns:
- the charset
-
setCharset
Sets the character set for encoding/decoding.- Parameters:
charset- the charset to use
-
start
Starts the SSH server with a callback for completion notification.- Parameters:
factory- the connection handler factory for new SSH sessionsdoneHandler- 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
-