Top Description Fields Constructors Methods
org.apache.sshd.server

public Class SshServer

extends AbstractFactoryManager
implements ServerFactoryManager
Class Inheritance
All Implemented Interfaces
org.apache.sshd.server.ServerFactoryManager, org.apache.sshd.server.ServerAuthenticationManager, org.apache.sshd.common.keyprovider.KeyPairProviderHolder, org.apache.sshd.common.auth.UserAuthFactoriesManager, org.apache.sshd.server.session.ServerProxyAcceptorHolder, org.apache.sshd.common.FactoryManager, org.apache.sshd.common.session.SessionHeartbeatController, org.apache.sshd.common.PropertyResolver, org.apache.sshd.common.AttributeStore, org.apache.sshd.common.AttributeRepository, org.apache.sshd.common.io.IoServiceEventListenerManager, org.apache.sshd.common.forward.PortForwardingEventListenerManager, org.apache.sshd.common.session.UnknownChannelReferenceHandlerManager, org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolverManager, org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolver, org.apache.sshd.common.channel.ChannelListenerManager, org.apache.sshd.common.session.SessionDisconnectHandlerManager, org.apache.sshd.common.session.ReservedSessionMessagesManager, org.apache.sshd.common.session.SessionListenerManager, org.apache.sshd.common.kex.KexFactoryManager, org.apache.sshd.common.kex.extension.KexExtensionHandlerManager, org.apache.sshd.common.signature.SignatureFactoriesManager, org.apache.sshd.common.signature.SignatureFactoriesHolder
Imports
java.io.IOException, java.net.InetAddress, .InetSocketAddress, .SocketAddress, .SocketTimeoutException, java.time.Duration, java.util.ArrayList, .Arrays, .Collections, .List, .Objects, .Set, java.util.concurrent.atomic.AtomicBoolean, org.apache.sshd.common.Closeable, .Factory, .PropertyResolverUtils, .ServiceFactory, org.apache.sshd.common.helpers.AbstractFactoryManager, org.apache.sshd.common.io.IoAcceptor, .IoServiceFactory, .IoSession, org.apache.sshd.common.keyprovider.HostKeyCertificateProvider, .KeyPairProvider, org.apache.sshd.common.session.helpers.AbstractSession, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.core.CoreModuleProperties, org.apache.sshd.server.auth.UserAuthFactory, org.apache.sshd.server.auth.gss.GSSAuthenticator, org.apache.sshd.server.auth.hostbased.HostBasedAuthenticator, org.apache.sshd.server.auth.keyboard.KeyboardInteractiveAuthenticator, org.apache.sshd.server.auth.password.PasswordAuthenticator, org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator, org.apache.sshd.server.command.CommandFactory, org.apache.sshd.server.session.ServerConnectionServiceFactory, .ServerProxyAcceptor, .ServerUserAuthServiceFactory, .SessionFactory, org.apache.sshd.server.shell.ShellFactory, org.apache.sshd.server.subsystem.SubsystemFactory

The SshServer class is the main entry point for the server side of the SSH protocol.

The SshServer has to be configured before being started. Such configuration can be done either using a dependency injection mechanism (such as the Spring framework) or programmatically. Basic setup is usually done using the setUpDefaultServer() method, which will known ciphers, macs, channels, etc... Besides this basic setup, a few things have to be manually configured such as the port number, Factory, the org.apache.sshd.common.keyprovider.KeyPairProvider and the PasswordAuthenticator.

Some properties can also be configured using the PropertyResolverUtils updateProperty methods.

Once the SshServer instance has been configured, it can be started using the start() method and stopped using the stop() method.
Author
Apache MINA SSHD Project
See Also
ServerFactoryManager, org.apache.sshd.common.FactoryManager

Field Summary

Modifier and TypeField and Description
protected IoAcceptor
private CommandFactory
public static final List<ServiceFactory>
public static final Factory<SshServer>
private GSSAuthenticator
protected String
private HostBasedAuthenticator
private HostKeyCertificateProvider
private KeyboardInteractiveAuthenticator
private KeyPairProvider
private PasswordAuthenticator
protected int
private ServerProxyAcceptor
private PublickeyAuthenticator
private SessionFactory
private ShellFactory
private final AtomicBoolean
private List<? extends SubsystemFactory>
private List<UserAuthFactory>
Inherited from org.apache.sshd.common.helpers.AbstractFactoryManager:
agentFactorychannelFactorieschannelListenerProxychannelListenersexecutorfileSystemFactoryforwarderFactoryforwardingFilterglobalRequestHandlersioServiceFactoryioServiceFactoryFactoryrandomFactoryserviceFactoriessessionListenerProxysessionListenerssessionTimeoutListenershutdownExecutortimeoutListenerFuturetunnelListenerProxytunnelListeners

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected IoAcceptor
protected SessionFactory
public List<AbstractSession>

Returns:

A List of the currently active session
getActiveSessions
()

Obtain the list of active sessions.

public Set<SocketAddress>

Returns:

The currently bound addresses - valid only after server started and while not stopped
getBoundAddresses
()

public CommandFactory
getCommandFactory()

Implements org.apache.sshd.server.ServerFactoryManager.getCommandFactory.

Retrieve the CommandFactory to be used to process commands requests.

public GSSAuthenticator
getGSSAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getGSSAuthenticator.

Retrieve the GSSAuthenticator to be used by the SSH server.

public String
public HostBasedAuthenticator
getHostBasedAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getHostBasedAuthenticator.

Retrieve the HostBasedAuthenticator to be used by the SSH server.

public HostKeyCertificateProvider
protected Closeable
public KeyboardInteractiveAuthenticator
getKeyboardInteractiveAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getKeyboardInteractiveAuthenticator.

Retrieve the KeyboardInteractiveAuthenticator to be used by the SSH server.

public KeyPairProvider
getKeyPairProvider()

Implements org.apache.sshd.common.keyprovider.KeyPairProviderHolder.getKeyPairProvider.

Retrieve the KeyPairProvider that will be used to find the host key to use on the server side or the user key on the client side.

public PasswordAuthenticator
getPasswordAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getPasswordAuthenticator.

Retrieve the PasswordAuthenticator to be used by the SSH server.

public int
public PublickeyAuthenticator
getPublickeyAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getPublickeyAuthenticator.

Retrieve the PublickeyAuthenticator to be used by SSH server.

public ServerProxyAcceptor
public SessionFactory
public ShellFactory
getShellFactory()

Implements org.apache.sshd.server.ServerFactoryManager.getShellFactory.

Retrieve the ShellFactory object to be used to create shells.

public List<? extends SubsystemFactory>
getSubsystemFactories()

Implements org.apache.sshd.server.ServerFactoryManager.getSubsystemFactories.

Retrieve the list of named factories for CommandFactory.Command to be used to create subsystems.

public List<UserAuthFactory>
getUserAuthFactories()

Implements org.apache.sshd.common.auth.UserAuthFactoriesManager.getUserAuthFactories.

Retrieve the list of named factories for UserAuth objects.

public boolean
public void
open()

public void
public void
public void
public void
public void
public void
public void
public void
public void
setPort(int
the port number for this SSH server
port
)

Configure the port number to use for this SSH server.

public void
public void
public void
public void
public void
setSubsystemFactories(List<? extends SubsystemFactory> subsystemFactories)

public static SshServer

Returns:

a newly create SshServer with default configurations
setUpDefaultServer
()

Setup a default server

public void
public void
start()

Start the SSH server and accept incoming exceptions on the configured port.

public void
stop()

Stop the SSH server.

public void
stop(boolean immediately)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.apache.sshd.common.helpers.AbstractFactoryManager:
addChannelListeneraddPortForwardingEventListeneraddSessionListenerattributeKeysclearAttributescomputeAttributeIfAbsentcreateSessionTimeoutListenergetAgentFactorygetAttributegetAttributesCountgetChannelFactoriesgetChannelListenerProxygetChannelStreamWriterResolvergetFileSystemFactorygetForwarderFactorygetForwardingFiltergetGlobalRequestHandlersgetIoServiceEventListenergetIoServiceFactorygetIoServiceFactoryFactorygetNioWorkersgetParentPropertyResolvergetPortForwardingEventListenerProxygetPropertiesgetRandomFactorygetReservedSessionMessagesHandlergetScheduledExecutorServicegetServiceFactoriesgetSessionDisconnectHandlergetSessionListenerProxygetUnknownChannelReferenceHandlergetVersionremoveAttributeremoveChannelListenerremovePortForwardingEventListenerremoveSessionListenerremoveSessionTimeoutresolveUnknownChannelReferenceHandlersetAgentFactorysetAttributesetChannelFactoriessetChannelStreamWriterResolversetFileSystemFactorysetForwarderFactorysetForwardingFiltersetGlobalRequestHandlerssetIoServiceEventListenersetIoServiceFactoryFactorysetNioWorkerssetParentPropertyResolversetRandomFactorysetReservedSessionMessagesHandlersetScheduledExecutorServicesetScheduledExecutorServicesetServiceFactoriessetSessionDisconnectHandlersetUnknownChannelReferenceHandlersetupSessionTimeoutstopSessionTimeoutListener

Field Detail

acceptorback to summary
protected IoAcceptor acceptor
commandFactoryback to summary
private CommandFactory commandFactory
DEFAULT_SERVICE_FACTORIESback to summary
public static final List<ServiceFactory> DEFAULT_SERVICE_FACTORIES
DEFAULT_SSH_SERVER_FACTORYback to summary
public static final Factory<SshServer> DEFAULT_SSH_SERVER_FACTORY
gssAuthenticatorback to summary
private GSSAuthenticator gssAuthenticator
hostback to summary
protected String host
hostBasedAuthenticatorback to summary
private HostBasedAuthenticator hostBasedAuthenticator
hostKeyCertificateProviderback to summary
private HostKeyCertificateProvider hostKeyCertificateProvider
interactiveAuthenticatorback to summary
private KeyboardInteractiveAuthenticator interactiveAuthenticator
keyPairProviderback to summary
private KeyPairProvider keyPairProvider
passwordAuthenticatorback to summary
private PasswordAuthenticator passwordAuthenticator
portback to summary
protected int port
proxyAcceptorback to summary
private ServerProxyAcceptor proxyAcceptor
publickeyAuthenticatorback to summary
private PublickeyAuthenticator publickeyAuthenticator
sessionFactoryback to summary
private SessionFactory sessionFactory
shellFactoryback to summary
private ShellFactory shellFactory
startedback to summary
private final AtomicBoolean started
subsystemFactoriesback to summary
private List<? extends SubsystemFactory> subsystemFactories
userAuthFactoriesback to summary
private List<UserAuthFactory> userAuthFactories

Constructor Detail

SshServerback to summary
public SshServer()

Method Detail

checkConfigback to summary
protected void checkConfig()

Overrides org.apache.sshd.common.helpers.AbstractFactoryManager.checkConfig.

Annotations
@Override
createAcceptorback to summary
protected IoAcceptor createAcceptor()
createSessionFactoryback to summary
protected SessionFactory createSessionFactory()
getActiveSessionsback to summary
public List<AbstractSession> getActiveSessions()

Obtain the list of active sessions.

Returns:List<AbstractSession>

A List of the currently active session

getBoundAddressesback to summary
public Set<SocketAddress> getBoundAddresses()
Returns:Set<SocketAddress>

The currently bound addresses - valid only after server started and while not stopped

getCommandFactoryback to summary
public CommandFactory getCommandFactory()

Implements org.apache.sshd.server.ServerFactoryManager.getCommandFactory.

Doc from org.apache.sshd.server.ServerFactoryManager.getCommandFactory.

Retrieve the CommandFactory to be used to process commands requests.

Returns:CommandFactory

A valid CommandFactory object or null if commands are not supported on this server

Annotations
@Override
getGSSAuthenticatorback to summary
public GSSAuthenticator getGSSAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getGSSAuthenticator.

Doc from org.apache.sshd.server.ServerAuthenticationManager.getGSSAuthenticator.

Retrieve the GSSAuthenticator to be used by the SSH server. If no authenticator has been configured (i.e. this method returns null), then client authentication requests based on gssapi will be rejected.

Returns:GSSAuthenticator

the GSSAuthenticator or null

Annotations
@Override
getHostback to summary
public String getHost()
getHostBasedAuthenticatorback to summary
public HostBasedAuthenticator getHostBasedAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getHostBasedAuthenticator.

Doc from org.apache.sshd.server.ServerAuthenticationManager.getHostBasedAuthenticator.

Retrieve the HostBasedAuthenticator to be used by the SSH server. If no authenticator has been configured (i.e. this method returns null), then client authentication requests based on this method will be rejected.

Returns:HostBasedAuthenticator

the HostBasedAuthenticator or null

Annotations
@Override
getHostKeyCertificateProviderback to summary
public HostKeyCertificateProvider getHostKeyCertificateProvider()

Implements org.apache.sshd.server.ServerAuthenticationManager.getHostKeyCertificateProvider.

Returns:HostKeyCertificateProvider

Doc from org.apache.sshd.server.ServerAuthenticationManager.getHostKeyCertificateProvider.

a HostKeyCertificateProvider if available, null as default

Annotations
@Override
getInnerCloseableback to summary
protected Closeable getInnerCloseable()

Implements abstract org.apache.sshd.common.util.closeable.AbstractInnerCloseable.getInnerCloseable.

Annotations
@Override
getKeyboardInteractiveAuthenticatorback to summary
public KeyboardInteractiveAuthenticator getKeyboardInteractiveAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getKeyboardInteractiveAuthenticator.

Doc from org.apache.sshd.server.ServerAuthenticationManager.getKeyboardInteractiveAuthenticator.

Retrieve the KeyboardInteractiveAuthenticator to be used by the SSH server. If no authenticator has been configured (i.e. this method returns null), then client authentication requests based on this method will be rejected.

Returns:KeyboardInteractiveAuthenticator

The KeyboardInteractiveAuthenticator or null

Annotations
@Override
getKeyPairProviderback to summary
public KeyPairProvider getKeyPairProvider()

Implements org.apache.sshd.common.keyprovider.KeyPairProviderHolder.getKeyPairProvider.

Doc from org.apache.sshd.common.keyprovider.KeyPairProviderHolder.getKeyPairProvider.

Retrieve the KeyPairProvider that will be used to find the host key to use on the server side or the user key on the client side.

Returns:KeyPairProvider

the KeyPairProvider, never null

Annotations
@Override
getPasswordAuthenticatorback to summary
public PasswordAuthenticator getPasswordAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getPasswordAuthenticator.

Doc from org.apache.sshd.server.ServerAuthenticationManager.getPasswordAuthenticator.

Retrieve the PasswordAuthenticator to be used by the SSH server. If no authenticator has been configured (i.e. this method returns null), then client authentication requests based on passwords will be rejected.

Returns:PasswordAuthenticator

the PasswordAuthenticator or null

Annotations
@Override
getPortback to summary
public int getPort()
getPublickeyAuthenticatorback to summary
public PublickeyAuthenticator getPublickeyAuthenticator()

Implements org.apache.sshd.server.ServerAuthenticationManager.getPublickeyAuthenticator.

Doc from org.apache.sshd.server.ServerAuthenticationManager.getPublickeyAuthenticator.

Retrieve the PublickeyAuthenticator to be used by SSH server. If no authenticator has been configured (i.e. this method returns null), then client authentication requests based on keys will be rejected.

Returns:PublickeyAuthenticator

the PublickeyAuthenticator or null

Annotations
@Override
getServerProxyAcceptorback to summary
public ServerProxyAcceptor getServerProxyAcceptor()

Implements org.apache.sshd.server.session.ServerProxyAcceptorHolder.getServerProxyAcceptor.

Annotations
@Override
getSessionFactoryback to summary
public SessionFactory getSessionFactory()
getShellFactoryback to summary
public ShellFactory getShellFactory()

Implements org.apache.sshd.server.ServerFactoryManager.getShellFactory.

Doc from org.apache.sshd.server.ServerFactoryManager.getShellFactory.

Retrieve the ShellFactory object to be used to create shells.

Returns:ShellFactory

a valid ShellFactory object or null if shells are not supported on this server

Annotations
@Override
getSubsystemFactoriesback to summary
public List<? extends SubsystemFactory> getSubsystemFactories()

Implements org.apache.sshd.server.ServerFactoryManager.getSubsystemFactories.

Doc from org.apache.sshd.server.ServerFactoryManager.getSubsystemFactories.

Retrieve the list of named factories for CommandFactory.Command to be used to create subsystems.

Returns:List<? extends SubsystemFactory>

a list of named SubsystemFactory-ies or null/empty if subsystems are not supported on this server

Annotations
@Override
getUserAuthFactoriesback to summary
public List<UserAuthFactory> getUserAuthFactories()

Implements org.apache.sshd.common.auth.UserAuthFactoriesManager.getUserAuthFactories.

Doc from org.apache.sshd.common.auth.UserAuthFactoriesManager.getUserAuthFactories.

Retrieve the list of named factories for UserAuth objects.

Returns:List<UserAuthFactory>

a list of named UserAuth factories, never null/empty

Annotations
@Override
isStartedback to summary
public boolean isStarted()
openback to summary
public void open() throws IOException
setCommandFactoryback to summary
public void setCommandFactory(CommandFactory commandFactory)
setGSSAuthenticatorback to summary
public void setGSSAuthenticator(GSSAuthenticator gssAuthenticator)

Implements org.apache.sshd.server.ServerAuthenticationManager.setGSSAuthenticator.

Annotations
@Override
setHostback to summary
public void setHost(String host)
setHostBasedAuthenticatorback to summary
public void setHostBasedAuthenticator(HostBasedAuthenticator hostBasedAuthenticator)

Implements org.apache.sshd.server.ServerAuthenticationManager.setHostBasedAuthenticator.

Annotations
@Override
setHostKeyCertificateProviderback to summary
public void setHostKeyCertificateProvider(HostKeyCertificateProvider hostKeyCertificateProvider)

Implements org.apache.sshd.server.ServerAuthenticationManager.setHostKeyCertificateProvider.

Annotations
@Override
setKeyboardInteractiveAuthenticatorback to summary
public void setKeyboardInteractiveAuthenticator(KeyboardInteractiveAuthenticator interactiveAuthenticator)

Implements org.apache.sshd.server.ServerAuthenticationManager.setKeyboardInteractiveAuthenticator.

Annotations
@Override
setKeyPairProviderback to summary
public void setKeyPairProvider(KeyPairProvider keyPairProvider)

Implements org.apache.sshd.common.keyprovider.KeyPairProviderHolder.setKeyPairProvider.

Annotations
@Override
setPasswordAuthenticatorback to summary
public void setPasswordAuthenticator(PasswordAuthenticator passwordAuthenticator)

Implements org.apache.sshd.server.ServerAuthenticationManager.setPasswordAuthenticator.

Annotations
@Override
setPortback to summary
public void setPort(int port)

Configure the port number to use for this SSH server.

Parameters
port:int

the port number for this SSH server

setPublickeyAuthenticatorback to summary
public void setPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator)

Implements org.apache.sshd.server.ServerAuthenticationManager.setPublickeyAuthenticator.

Annotations
@Override
setServerProxyAcceptorback to summary
public void setServerProxyAcceptor(ServerProxyAcceptor proxyAcceptor)

Implements org.apache.sshd.server.session.ServerProxyAcceptorHolder.setServerProxyAcceptor.

Annotations
@Override
setSessionFactoryback to summary
public void setSessionFactory(SessionFactory sessionFactory)
setShellFactoryback to summary
public void setShellFactory(ShellFactory shellFactory)
setSubsystemFactoriesback to summary
public void setSubsystemFactories(List<? extends SubsystemFactory> subsystemFactories)
setUpDefaultServerback to summary
public static SshServer setUpDefaultServer()

Setup a default server

Returns:SshServer

a newly create SshServer with default configurations

setUserAuthFactoriesback to summary
public void setUserAuthFactories(List<UserAuthFactory> userAuthFactories)

Implements org.apache.sshd.common.auth.UserAuthFactoriesManager.setUserAuthFactories.

Annotations
@Override
startback to summary
public void start() throws IOException

Start the SSH server and accept incoming exceptions on the configured port. Ignored if already started

Exceptions
IOException:
If failed to start
stopback to summary
public void stop() throws IOException

Stop the SSH server. This method will block until all resources are actually disposed.

Exceptions
IOException:
if stopping failed somehow
stopback to summary
public void stop(boolean immediately) throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override