Package org.dellroad.jct.ssh.simple
Class SimpleConsoleSshServer.Builder
java.lang.Object
org.dellroad.jct.ssh.simple.SimpleConsoleSshServer.Builder
- Enclosing class:
- SimpleConsoleSshServer
Builder for new
SimpleConsoleSshServer
instances.
The following properties are required: console, authenticator, and host key.
-
Method Summary
Modifier and TypeMethodDescriptionauthenticator
(org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator authenticator) Configure the public key authenticator that authenticates new incoming connections.authorizedKeys
(InputStream authorizedKeys) Read authorized users' public keys from anInputStream
.authorizedKeys
(String authorizedKeys) Read authorized users' public keys from aString
.authorizedKeys
(Path authorizedKeys) Configurea authorized users' public keys to be read from a file at connection time.build()
Build a newSimpleConsoleSshServer
based on this instance.Configure theExec
that successful incoming execute connections should connect to.hostKey
(ClassLoader loader, String resource) Configure the host key to be read from a classpath resource at connection time.Configure the host key to be read from a file at connection time.hostKeyProvider
(org.apache.sshd.common.keyprovider.KeyPairProvider hostKeyProvider) Configure the host key provider.listenPort
(int port) Configure the TCP port on which to listen for new connections.loopbackOnly
(boolean loopbackOnly) Configure whether to listen for new connections only on the loopback interface, or on all interfaces.Configure theShell
that successful incoming shell connections should connect to.
-
Method Details
-
exec
Configure theExec
that successful incoming execute connections should connect to.This property or
#shell shell()
is required.- Parameters:
exec
- target exec- Returns:
- this instance
-
shell
Configure theShell
that successful incoming shell connections should connect to.This property or
#shell shell()
is required.- Parameters:
shell
- target shell- Returns:
- this instance
-
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
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
- ifport
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 aString
.- Parameters:
authorizedKeys
- the content of an opensshauthorized_keys
file- Returns:
- this instance
- Throws:
IOException
- ifauthorizedKeys
contains invalid contentGeneralSecurityException
- if public key data could not be parsedIllegalArgumentException
- ifauthorizedKeys
is null
-
authorizedKeys
public SimpleConsoleSshServer.Builder authorizedKeys(InputStream authorizedKeys) throws IOException, GeneralSecurityException Read authorized users' public keys from anInputStream
.The given stream will not be closed by this method.
- Parameters:
authorizedKeys
- input from an opensshauthorized_keys
file- Returns:
- this instance
- Throws:
IOException
- ifauthorizedKeys
contains invalid contentGeneralSecurityException
- if public key data could not be parsedIllegalArgumentException
- ifauthorizedKeys
is null
-
authorizedKeys
Configurea authorized users' public keys to be read from a file at connection time.- Parameters:
authorizedKeys
- opensshauthorized_keys
file- Returns:
- this instance
- Throws:
IllegalArgumentException
- ifauthorizedKeys
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
Configure the host key to be read from a file at connection time.- Parameters:
hostKey
- openssh host key file- Returns:
- this instance
- Throws:
IllegalArgumentException
- ifhostKey
is null
-
hostKey
Configure the host key to be read from a classpath resource at connection time.- Parameters:
loader
- class loaderresource
- classpath resource- Returns:
- this instance
- Throws:
IllegalArgumentException
- if either parameter is null
-
build
Build a newSimpleConsoleSshServer
based on this instance.- Returns:
- new server configured by this instance
- Throws:
IllegalArgumentException
- if this builder is incompletely configured
-