public class SshServerContext extends SshContext
byteBufferPool, CIPHER_AES128_CBC, CIPHER_AES128_CTR, CIPHER_AES192_CBC, CIPHER_AES192_CTR, CIPHER_AES256_CBC, CIPHER_AES256_CTR, CIPHER_ARCFOUR, CIPHER_ARCFOUR_128, CIPHER_ARCFOUR_256, CIPHER_BLOWFISH_CBC, CIPHER_TRIPLEDES_CBC, CIPHER_TRIPLEDES_CTR, ciphersCS, ciphersSC, COMPRESSION_NONE, COMPRESSION_ZLIB, compressionLevel, compressionsCS, compressionsSC, daemon, executor, forwardingBufferMaxQueueCount, forwardingPolicy, HMAC_MD5, HMAC_MD5_96, HMAC_MD5_ETM, HMAC_RIPEMD160, HMAC_RIPEMD160_ETM, HMAC_SHA1, HMAC_SHA1_96, HMAC_SHA1_ETM, HMAC_SHA256, HMAC_SHA256_96, HMAC_SHA256_ETM, HMAC_SHA512, HMAC_SHA512_96, HMAC_SHA512_ETM, idleAuthenticationTimeoutSeconds, idleConnectionTimeout, keepAliveDataMaxLength, keepAliveInterval, KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA1, KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256, KEX_DIFFIE_HELLMAN_GROUP1_SHA1, KEX_DIFFIE_HELLMAN_GROUP14_SHA1, KEYBOARD_INTERACTIVE_AUTHENTICATION, keyExchanges, killTunnelsOnRemoteForwardingCancel, locale, macCS, macSC, MAX_NUM_BYTES_BEFORE_REKEY, MAX_NUM_PACKETS_BEFORE_REKEY, maxAuthentications, maxChannels, maximumPacketLength, maximumSocketsBacklogPerRemotelyForwardedConnection, minDHGroupExchangeKeySize, PASSWORD_AUTHENTICATION, prefCipherCS, prefCipherSC, prefCompressionCS, prefCompressionSC, prefKeyExchange, prefMacCS, prefMacSC, prefPublicKey, PUBLIC_KEY_ECDSA_SHA2_NISPTP_256, PUBLIC_KEY_ECDSA_SHA2_NISPTP_384, PUBLIC_KEY_ECDSA_SHA2_NISPTP_521, PUBLIC_KEY_SSHDSS, PUBLIC_KEY_SSHRSA, PUBLICKEY_AUTHENTICATION, publicKeys, socketConnectionFactory, softwareVersionComments
keepAlive, receiveBufferSize, reuseAddress, sendBufferSize, tcpNoDelay
Constructor and Description |
---|
SshServerContext(SshEngine engine) |
SshServerContext(SshEngine engine,
ComponentManager componentManager) |
Modifier and Type | Method and Description |
---|---|
void |
addCommand(String name,
Class<? extends ExecutableCommand> cls)
Add an
com.maverick.sshd.ExecutableCommand to the configuration. |
void |
addGlobalRequestHandler(GlobalRequestHandler<SshServerContext> handler) |
void |
addHostKey(SshKeyPair keyPair)
Add a host key to the configuration.
|
void |
addHostKeys(Collection<SshKeyPair> keys)
Add a collection of host keys.
|
void |
addStateListener(ConnectionStateListener<SshServerContext> stateListener) |
protected void |
configureKeyExchanges() |
boolean |
containsCommand(String name)
Determine whether a command is configured.
|
ProtocolEngine |
createEngine(ConnectRequestFuture connectFuture)
Create a protocol engine.
|
static SshKeyPair |
generateKeyFiles(File keyFilename,
String type,
int bitlength,
int publicKeyFormat)
Generate a public and private key pair, save them to keyFilename and
keyFilename.pub, return the key pair
|
boolean |
getAllowDeniedKEX() |
AuthenticationMechanismFactory |
getAuthenticationMechanismFactory() |
String |
getBannerMessage()
Get the authentication banner to display to connecting clients.
|
ChannelFactory<SshServerContext> |
getChannelFactory() |
Class<? extends ExecutableCommand> |
getCommand(String name)
Get the Class implementation for a given command.
|
ConnectionManager<SshServerContext> |
getConnectionManager() |
long |
getConnectionUploadQuota() |
String |
getDefaultTerminal()
Get the default terminal to execute when the user requests to start a
shell.
|
AbstractFileFactory<?> |
getFileFactory()
Get the file factory for this context.
|
ForwardingManager<SshServerContext> |
getForwardingManager() |
GlobalRequestHandler<SshServerContext> |
getGlobalRequestHandler(String name) |
SshKeyPair |
getHostKey(String algorithm)
Get the host key for a given algorithm.
|
SshKeyPair[] |
getHostKeys()
Get all the hosts keys.
|
IPPolicy |
getIPPolicy() |
int |
getMaxConcurrentTransfers() |
int |
getMaximumConnections()
Get the maximum number of connections allowed at any one time.
|
int |
getMaximumNumberOfAsyncSFTPRequests() |
int |
getMaximumPublicKeyVerificationAttempts()
Get the number of public keys that each user can attempt to verify for
public key authentication.
|
String |
getPreferredPublicKey()
Get the currently preferred public key algorithm.
|
int |
getSessionTimeout()
Returns the session timeout in seconds
|
String |
getSFTPCharsetEncoding()
Get the current encoding value for filenames in SFTP sessions.
|
String |
getSFTPLongnameDateFormat() |
String |
getSFTPLongnameDateFormatWithTime() |
int |
getSFTPVersion() |
ShellPolicy |
getShellPolicy() |
Collection<ConnectionStateListener<SshServerContext>> |
getStateListeners() |
String |
getSupportedPublicKeys()
Returns a comma delimited string containing installed public key types.
|
String |
getTooManyConnectionsText() |
String |
getWelcomeText() |
boolean |
hasPublicKey(String algorithm)
Determine if the server has a host key configured.
|
boolean |
isAllowZeroLengthFileUpload() |
boolean |
isEnsureGracefulDisconnect() |
boolean |
isPublicKeyVerificationFailedAuth() |
boolean |
isSCPReadWriteEvents() |
boolean |
isSFTPReadWriteEvents() |
void |
loadHostKey(InputStream in,
String type,
int bitlength) |
void |
loadHostKey(InputStream in,
String type,
int bitlength,
int privateKeyFormat,
int publicKeyFormat,
String passPhrase) |
void |
loadHostKey(InputStream in,
String type,
int bitlength,
String passPhrase) |
SshKeyPair |
loadKey(File key,
String passphrase) |
SshKeyPair |
loadKey(InputStream in,
String passphrase) |
void |
loadKeystore(File keystoreFile,
String alias,
String storePassphrase,
String keyPassphrase)
Load a keystore for use as an SSH host key.
|
void |
loadKeystore(File keystoreFile,
String alias,
String storePassphrase,
String keyPassphrase,
String storeType) |
void |
loadKeystore(InputStream in,
String alias,
String storePassphrase,
String keyPassphrase) |
void |
loadKeystore(InputStream in,
String alias,
String storePassphrase,
String keyPassphrase,
String storeType) |
void |
loadOrGenerateHostKey(File key,
String type,
int bitlength)
Load a host key from file, if the file does not exist then generate the
key.
|
void |
loadOrGenerateHostKey(File key,
String type,
int bitlength,
int publicKeyFormat,
String passPhrase)
Load a host key from file, if the file does not exist then generate the
key.
|
void |
loadOrGenerateHostKey(File key,
String type,
int bitlength,
String passPhrase) |
void |
loadSshCertificate(File keyFile,
String passphrase,
File certFile) |
void |
setAllowDeniedKEX(boolean allowKeyExchangeForDeniedConnection) |
void |
setAllowZeroLengthFileUpload(boolean allowZeroLengthFileUpload) |
void |
setAuthenicationMechanismFactory(AuthenticationMechanismFactory authFactory) |
void |
setBannerMessage(String authenticationBanner)
Set the banner message that is displayed to all connecing clients prior
to authentication.
|
void |
setChannelFactory(ChannelFactory<SshServerContext> channelFactory) |
void |
setConnectionManager(ConnectionManager<SshServerContext> connectionManager) |
void |
setConnectionUploadQuota(long perConnectionUploadQuota) |
void |
setDefaultTerminal(String defaultTerminal)
Set the default terminal to execute when the user requests to start a
shell.
|
void |
setFileFactory(AbstractFileFactory<?> fileFactory)
Set the file factory for this context.
|
void |
setForwardingManager(ForwardingManager<SshServerContext> forwardingManager) |
void |
setIPPolicy(IPPolicy ipPolicy) |
void |
setMaxConcurrentTransfers(int maxConcurrentTransfers) |
void |
setMaximumConnections(int maximumConnections)
Set the maximum number of connections allowed at any one time.
|
void |
setMaximumNumberofAsyncSFTPRequests(int maximumSftpRequests) |
void |
setMaximumPublicKeyVerificationAttempts(int maximumPublicKeyVerificationAttempts)
Set the number of public keys that a user can verify for public key
authentication.
|
void |
setPreferredPublicKey(String name)
Set the preferred public key algorithm.
|
void |
setPublicKeyVerificationIsFailedAuth(boolean publicKeyVerificationIsFailedAuth) |
void |
setSCPReadWriteEvents(boolean scpReadWriteEvents) |
void |
setSessionTimeout(int sessionTimeoutSeconds)
Sets the session timeout in seconds
|
void |
setSFTPCharsetEncoding(String sftpCharsetEncoding)
Set the default encoding for filenames in SFTP sessions.
|
void |
setSFTPReadWriteEvents(boolean sftpReadWriteEvents) |
void |
setShellPolixy(ShellPolicy shellPolicy) |
void |
setSupportedSFTPVersion(int sftpVersion) |
void |
setTooManyConnectionsText(String tooManyConnectionsText) |
void |
setWelcomeText(String welcomeText) |
addOperationListener, enableFIPSMode, getByteBufferPool, getChannelLimit, getCiphersCS, getCiphersSC, getComponentManager, getCompressionLevel, getDaemonContext, getEngine, getExecutorListeners, getExecutorService, getForwardingBufferMaxQueueCount, getForwardingPolicy, getIdleAuthenticationTimeoutSeconds, getIdleConnectionTimeoutSeconds, getKeepAliveDataMaxLength, getKeepAliveInterval, getKeyExchangePacketLimit, getKeyExchanges, getKeyExchangeTransferLimit, getLocale, getMacsCS, getMacsSC, getMaxAuthentications, getMaximumPacketLength, getMaximumSocketsBacklogPerRemotelyForwardedConnection, getMinDHGroupExchangeKeySize, getPreferredCipherCS, getPreferredCipherSC, getPreferredCompressionCS, getPreferredCompressionSC, getPreferredKeyExchange, getPreferredMacCS, getPreferredMacSC, getPublicKeys, getRemoteForwardingCancelKillsTunnels, getSocketConnectionFactory, getSoftwareVersionComments, init, listPublicKeys, removeOperationListener, setChannelLimit, setCipherPreferredPositionCS, setCipherPreferredPositionSC, setCompressionLevel, setForwardingBufferMaxQueueCount, setForwardingPolicy, setIdleAuthenticationTimeoutSeconds, setIdleConnectionTimeoutSeconds, setKeepAliveDataMaxLength, setKeepAliveInterval, setKeyExchangePacketLimit, setKeyExchangePreferredPosition, setKeyExchangeTransferLimit, setLocale, setMacPreferredPositionCS, setMacPreferredPositionSC, setMaxAuthentications, setMaximumPacketLength, setMaximumSocketsBacklogPerRemotelyForwardedConnection, setMinDHGroupExchangeKeySize, setPreferredCipherCC, setPreferredCipherCS, setPreferredCipherCS, setPreferredCipherSC, setPreferredCipherSC, setPreferredCipherSC, setPreferredCompressionCS, setPreferredCompressionSC, setPreferredKeyExchange, setPreferredKeyExchange, setPreferredMacCS, setPreferredMacCS, setPreferredMacCS, setPreferredMacSC, setPreferredMacSC, setPreferredMacSC, setPublicKeyPreferredPosition, setRemoteForwardingCancelKillsTunnels, setSocketConnectionFactory, setSoftwareVersionComments, shutdown, supportedCiphersCS, supportedCiphersSC, supportedCompressionsCS, supportedCompressionsSC, supportedKeyExchanges, supportedMacsCS, supportedMacsSC, supportedPublicKeys
createConnection, createConnectionImpl, getReceiveBufferSize, getSendBufferSize, getSocketOptionKeepAlive, getSocketOptionReuseAddress, getSocketOptionTcpNoDelay, setReceiveBufferSize, setSendBufferSize, setSocketHandlerImpl, setSocketOptionKeepAlive, setSocketOptionReuseAddress, setSocketOptionTcpNoDelay
public SshServerContext(SshEngine engine, ComponentManager componentManager) throws IOException
IOException
public SshServerContext(SshEngine engine) throws IOException
IOException
public ConnectionManager<SshServerContext> getConnectionManager()
getConnectionManager
in class SshContext
public void setConnectionManager(ConnectionManager<SshServerContext> connectionManager)
public ProtocolEngine createEngine(ConnectRequestFuture connectFuture) throws IOException
ProtocolContext
createEngine
in class SshContext
IOException
public void addStateListener(ConnectionStateListener<SshServerContext> stateListener)
public Collection<ConnectionStateListener<SshServerContext>> getStateListeners()
public void addGlobalRequestHandler(GlobalRequestHandler<SshServerContext> handler)
public GlobalRequestHandler<SshServerContext> getGlobalRequestHandler(String name)
getGlobalRequestHandler
in class SshContext
public String getBannerMessage()
public void setBannerMessage(String authenticationBanner)
authenticationBanner
- public String getSFTPCharsetEncoding()
public void setSFTPCharsetEncoding(String sftpCharsetEncoding)
sftpCharsetEncoding
- Stringpublic int getSessionTimeout()
public void setSessionTimeout(int sessionTimeoutSeconds)
sessionTimeoutSeconds
- intpublic void setMaximumConnections(int maximumConnections)
maximumConnections
- intpublic int getMaximumConnections()
public int getMaximumPublicKeyVerificationAttempts()
public void setMaximumPublicKeyVerificationAttempts(int maximumPublicKeyVerificationAttempts)
maximumPublicKeyVerificationAttempts
- intpublic String getPreferredPublicKey()
getPreferredPublicKey
in class SshContext
public String getSupportedPublicKeys()
getSupportedPublicKeys
in class SshContext
public void setPreferredPublicKey(String name) throws IOException, SshException
Set the preferred public key algorithm.
This value must be one of the installed public key algorithm names.
You will be able to obtain these from the public keys that you installed using ??????
and an example of how to do this is provided in the
ConfigurationContext#addHostKey(SshKeyPair)
method description.
name
- IOException
SshException
public SshKeyPair[] getHostKeys()
public SshKeyPair getHostKey(String algorithm) throws IOException
algorithm
- IOException
public void addHostKey(SshKeyPair keyPair) throws IOException
Add a host key to the configuration.
A host key provides a mechanism for a client to authenticate the server. If the client knows the public key of the server it can validate the signature that the server generated using its private key with the known public key of the server. In order for your server to operate you need to generate and install at least one host key.
It is now recommended to use the
SshDaemon#loadOrGenerateHostKey(File, String, int, ConfigurationContext)
method for generating and loading a host key.
keyPair
- IOException
public void addHostKeys(Collection<SshKeyPair> keys) throws IOException
keys
- IOException
public ChannelFactory<SshServerContext> getChannelFactory()
getChannelFactory
in class SshContext
public void setChannelFactory(ChannelFactory<SshServerContext> channelFactory)
public ForwardingManager<SshServerContext> getForwardingManager()
getForwardingManager
in class SshContext
public void setForwardingManager(ForwardingManager<SshServerContext> forwardingManager)
public void addCommand(String name, Class<? extends ExecutableCommand> cls)
com.maverick.sshd.ExecutableCommand
to the configuration.
If a request to execute a command with the name name is received
an instance of the class is created to handle the command execution.name
- Stringcls
- Classpublic boolean containsCommand(String name)
name
- Stringpublic Class<? extends ExecutableCommand> getCommand(String name)
name
- Stringpublic boolean hasPublicKey(String algorithm)
algorithm
- public void setFileFactory(AbstractFileFactory<?> fileFactory)
fileFactory
- public AbstractFileFactory<?> getFileFactory()
public String getDefaultTerminal()
Get the default terminal to execute when the user requests to start a shell.
This setting is not used explicitly by the server but is available from
the context so that a session implementation can obtain it through the
protected ConnectionProtocol
instance.
public void setDefaultTerminal(String defaultTerminal)
Set the default terminal to execute when the user requests to start a shell.
This setting is not used explicitly by the server but is available from
the context so that a session implementation can obtain it through the
protected ConnectionProtocol
instance.
defaultTerminal
- public void loadOrGenerateHostKey(File key, String type, int bitlength) throws IOException, InvalidPassphraseException, SshException
key
- the key filetype
- the type of key; acceptable values are
SshKeyPairGenerator.SSH2_RSA or SshKeyPairGenerator.SSH2_DSAbitlength
- the bit length of the keyIOException
SshException
InvalidPassphraseException
public void loadOrGenerateHostKey(File key, String type, int bitlength, String passPhrase) throws IOException, InvalidPassphraseException, SshException
public void loadHostKey(InputStream in, String type, int bitlength) throws IOException, InvalidPassphraseException, SshException
public void loadHostKey(InputStream in, String type, int bitlength, String passPhrase) throws IOException, InvalidPassphraseException, SshException
public void loadOrGenerateHostKey(File key, String type, int bitlength, int publicKeyFormat, String passPhrase) throws IOException, InvalidPassphraseException, SshException
key
- the key filetype
- the type of key; acceptable values are
SshKeyPairGenerator.SSH2_RSA or SshKeyPairGenerator.SSH2_DSAbitlength
- the bit length of the keyprivateKeyFormat
- the format of the private key, com.sshtools.publickey.SshPrivateKeyFileFactory
publicKeyFormat
- the format of the public key, {see
com.sshtools.publickey.SshPublicKeyFileFactory}passPhrase
- the passPhrase of an existing host keyIOException
SshException
InvalidPassphraseException
public void loadHostKey(InputStream in, String type, int bitlength, int privateKeyFormat, int publicKeyFormat, String passPhrase) throws IOException, InvalidPassphraseException, SshException
public SshKeyPair loadKey(File key, String passphrase) throws IOException, InvalidPassphraseException
public SshKeyPair loadKey(InputStream in, String passphrase) throws IOException, InvalidPassphraseException
public static SshKeyPair generateKeyFiles(File keyFilename, String type, int bitlength, int publicKeyFormat) throws IOException, SshException
keyFilename
- type
- bitlength
- privateKeyFormat
- publicKeyFormat
- IOException
SshException
public void loadKeystore(File keystoreFile, String alias, String storePassphrase, String keyPassphrase) throws IOException
keystoreFile
- path to the keystore filealias
- the alias of the key in the keystorestorePassphrase
- the passphrase of the keystorekeyPassphrase
- the passphrase of the keyIOException
public void loadKeystore(InputStream in, String alias, String storePassphrase, String keyPassphrase) throws IOException
IOException
public void loadKeystore(File keystoreFile, String alias, String storePassphrase, String keyPassphrase, String storeType) throws IOException
IOException
public void loadKeystore(InputStream in, String alias, String storePassphrase, String keyPassphrase, String storeType) throws IOException
IOException
public void setAllowDeniedKEX(boolean allowKeyExchangeForDeniedConnection)
public boolean getAllowDeniedKEX()
public String getTooManyConnectionsText()
public void setTooManyConnectionsText(String tooManyConnectionsText)
public boolean isAllowZeroLengthFileUpload()
public void setAllowZeroLengthFileUpload(boolean allowZeroLengthFileUpload)
allowZeroLengthFileUpload
- public void setMaxConcurrentTransfers(int maxConcurrentTransfers)
public int getMaxConcurrentTransfers()
public void setPublicKeyVerificationIsFailedAuth(boolean publicKeyVerificationIsFailedAuth)
public boolean isPublicKeyVerificationFailedAuth()
public void setSupportedSFTPVersion(int sftpVersion)
public int getSFTPVersion()
public void loadSshCertificate(File keyFile, String passphrase, File certFile) throws IOException, InvalidPassphraseException
public AuthenticationMechanismFactory getAuthenticationMechanismFactory()
public void setAuthenicationMechanismFactory(AuthenticationMechanismFactory authFactory)
public String getWelcomeText()
public void setWelcomeText(String welcomeText)
public ShellPolicy getShellPolicy()
public void setShellPolixy(ShellPolicy shellPolicy)
public IPPolicy getIPPolicy()
public void setIPPolicy(IPPolicy ipPolicy)
public void setConnectionUploadQuota(long perConnectionUploadQuota)
public long getConnectionUploadQuota()
public void setSFTPReadWriteEvents(boolean sftpReadWriteEvents)
public boolean isSFTPReadWriteEvents()
public void setSCPReadWriteEvents(boolean scpReadWriteEvents)
public boolean isSCPReadWriteEvents()
public boolean isEnsureGracefulDisconnect()
protected void configureKeyExchanges()
configureKeyExchanges
in class SshContext
public int getMaximumNumberOfAsyncSFTPRequests()
public void setMaximumNumberofAsyncSFTPRequests(int maximumSftpRequests)
public String getSFTPLongnameDateFormat()
public String getSFTPLongnameDateFormatWithTime()
Copyright © 2016. All rights reserved.