public class SshContext extends ProtocolContext implements ExecutorServiceProvider
Daemon
.keepAlive, receiveBufferSize, reuseAddress, sendBufferSize, tcpNoDelay
Constructor and Description |
---|
SshContext()
Constructs a default context but does not set the daemon
|
SshContext(Daemon daemon)
Constructs a default context
|
SshContext(Daemon daemon,
SecurityLevel securityLevel) |
Modifier and Type | Method and Description |
---|---|
void |
addCommand(String name,
Class<? extends ExecutableCommand> cls)
Add an
com.maverick.sshd.ExecutableCommand to the configuration. |
void |
addEventListener(EventListener listener) |
void |
addGlobalRequestHandler(GlobalRequestHandler handler) |
void |
addHostKey(SshKeyPair keyPair)
Add a host key to the configuration.
|
void |
addRequiredAuthentication(String method)
Set an authentication method as required.
|
void |
addSFTPExtensionFactory(SftpExtensionFactory factory) |
boolean |
containsCommand(String name)
Determine whether a command is configured.
|
ProtocolEngine |
createEngine()
Create a protocol engine.
|
int |
decrementConnections() |
void |
enableFIPSMode()
Deprecated.
This method is out-of-date. Use JCEProvider.initializeDefaultProvider("BCFIPS") passing a FIPS approved JCE provider
in approved mode to restrict algorithms to only those supported by the approved FIPS environment.
|
void |
enableSFTPVersion4()
Deprecated.
|
static SshKeyPair |
GenerateKeyFiles(File keyFilename,
String type,
int bitlength,
int privateKeyFormat,
int publicKeyFormat)
Deprecated.
use generateKeyFiles instead.
|
static SshKeyPair |
generateKeyFiles(File keyFilename,
String type,
int bitlength,
int privateKeyFormat,
int publicKeyFormat,
String passphrase)
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.
|
ByteBufferPool |
getByteBufferPool() |
int |
getChannelDataTimeoutSeconds() |
ChannelFactory |
getChannelFactory() |
int |
getChannelLimit()
Get the maximum number of open channels allowed by each client.
|
String |
getCiphersCS() |
String |
getCiphersSC()
Get the ciphers for the Server->Client stream.
|
Class<? extends ExecutableCommand> |
getCommand(String name)
Get the Class implementation for a given command.
|
int |
getCompressionLevel()
Get the current compression level
|
int |
getConnections() |
long |
getConnectionUploadQuota() |
DaemonContext |
getDaemonContext() |
String |
getDefaultTerminal()
Get the default terminal to execute when the user requests to start a
shell.
|
boolean |
getDisableSFTPDirChecks() |
List<EventListener> |
getEventListeners() |
ExecutorService |
getExecutorService() |
FileSystemFactory |
getFileSystemProvider()
Get the
FileSystem for this SSHD
instance. |
int |
getForwardingBufferMaxQueueCount() |
ForwardingCallback |
getForwardingCallback()
Get the forwarding callback implementation for this server context.
|
ForwardingPolicy |
getForwardingPolicy() |
GlobalRequestHandler |
getGlobalRequestHandler(String requestname) |
SshKeyPair |
getHostKey(String algorithm)
Get the SSHD host key for a given algorithm.
|
SshKeyPair[] |
getHostKeys()
Get all the hosts keys.
|
String |
getHttpRedirectUrl() |
int |
getIdleAuthenticationTimeoutSeconds() |
int |
getIdleConnectionTimeoutSeconds()
Should the connection be disconnected on session timeout?
|
IPPolicy |
getIPPolicy() |
int |
getKeepAliveDataMaxLength()
Get the maximum data length for the keep-alive packet.
|
int |
getKeepAliveInterval()
Get the current keep-alive interval (in seconds).
|
Configuration |
getKerberosConfiguration()
Get the custom Kerberos configuration.
|
String |
getKerberosDC()
Get the Kerberos domain controller address .
|
String |
getKerberosRealm()
Get the realm name to use for GSSAPI Kerberos authentication.
|
char[] |
getKerberosServicePassword()
Get the Kerberos service account password.
|
String |
getKerberosServicePrincipal()
Get the Kerberos service account password.
|
int |
getKeyExchangePacketLimit()
Get the number of packets to send before a key exchange is forced
|
String |
getKeyExchanges()
Get the ciphers for the Server->Client stream.
|
int |
getKeyExchangeTransferLimit()
Get the number of bytes to transfer before a key exchange is forced.
|
LoadBalancerPolicy |
getLoadBalancerPolicy() |
Locale |
getLocale() |
String |
getMacsCS()
Get the ciphers for the Client->Server stream.
|
String |
getMacsSC()
Get the ciphers for the Server->Client stream.
|
int |
getMaxAuthentications()
Get the maximum number of failed authentications allowed for each
connection.
|
int |
getMaxConcurrentTransfers() |
int |
getMaxDHGroupExchangeKeySize() |
int |
getMaximumChannelsPerConnection() |
int |
getMaximumConnections()
Get the maximum number of connections allowed at any one time.
|
int |
getMaximumNumberOfAsyncSFTPRequests()
Deprecated.
This setting is redundant
|
int |
getMaximumPacketLength()
Get the maximum supported length of an SSH packet.
|
int |
getMaximumPublicKeyVerificationAttempts()
Get the number of public keys that each user can attempt to verify for
public key authentication.
|
int |
getMaximumSFTPWindowSpace() |
int |
getMaximumSocketsBacklogPerRemotelyForwardedConnection() |
int |
getMaximumUserConnections()
Get the maximum number of connections a user is allowed at any one time.
|
int |
getMaxSessions() |
int |
getMaxumumSessionWindowSpace() |
MessagePolicy |
getMessagePolicy() |
int |
getMinDHGroupExchangeKeySize() |
int |
getMinimumRemotePacketSize() |
int |
getMinimumSFTPWindowSapce() |
String |
getPreferredCipherCS()
Get the currently preferred cipher for the Client->Server stream.
|
String |
getPreferredCipherSC()
Get the currently preferred cipher for the Server->Client stream.
|
String |
getPreferredCompressionCS()
Get the currently preferred compression for the Client->Server stream.
|
String |
getPreferredCompressionSC()
Get the currently preferred compression for the Server->Client stream.
|
String |
getPreferredKeyExchange()
Get the currently preferred key exchange method.
|
String |
getPreferredMacCS()
Get the currently preferred mac for the Client->Server stream.
|
String |
getPreferredMacSC()
Get the currently supported mac for the Server-Client stream.
|
String |
getPreferredPublicKey()
Get the currently preferred public key algorithm.
|
boolean |
getPreventDirectoryDuplicateReadsPerChannel() |
PublicKeyAuthenticationVerifier |
getPublicKeyAuthenticationVerifier() |
String |
getPublicKeys()
Get the ciphers for the Server->Client stream.
|
boolean |
getRemoteForwardingCancelKillsTunnels()
Determines whether the cancellation of a remote forwarding drops
currently active tunnels
|
Class<? extends RemoteForwardingFactory> |
getRemoteForwardingFactoryImpl() |
Class<? extends RemoteForwardingManager> |
getRemoteForwardingManagerImpl() |
String[] |
getRequiredAuthentications()
Lists the required authentication methods.
|
RequiredAuthenticationStrategy |
getRequiredAuthenticationStrategy() |
SecurityLevel |
getSecurityLevel() |
Daemon |
getServer()
Get the instance of the SSHD for this context.
|
int |
getSessionTimeout()
Returns the session timeout in seconds
|
String |
getSFTPCharsetEncoding()
Get the current encoding value for filenames in SFTP sessions.
|
SftpExtension |
getSFTPExtension(String requestName) |
List<SftpExtensionFactory> |
getSFTPExtensionFactories() |
String |
getSFTPLongnameDateFormat() |
String |
getSFTPLongnameDateFormatWithTime() |
int |
getSFTPVersion() |
Class<? extends ExecutableCommand> |
getShellCommand()
Get an
ExecutableCommand
implementation that provides the default shell. |
ShellPolicy |
getShellPolicy() |
String |
getSoftwareVersionComments()
Get the software/version/comments field that is to be used in the SSH
protocols negotiation procedure.
|
String |
getSupportedPublicKeys()
Returns a comma delimited string containing installed public key types.
|
String |
getTooManyConnectionsText() |
UsernamePolicy |
getUsernamePolicy() |
String |
getWelcomeText() |
boolean |
getWriteSCPBaseDir() |
boolean |
hasPublicKey(String algorithm)
Determine if the server has a host key configured.
|
int |
incrementConnections() |
void |
init(Daemon daemon)
Initialise the SshContext by setting the daemon
|
boolean |
isAllowZeroLengthFileUpload() |
boolean |
isEnableETM() |
boolean |
isHttpRedirect() |
boolean |
isKeyExchangeDisabled() |
boolean |
isManagedSFTPWindow()
Deprecated.
|
boolean |
isNonStandardAlgorithmsEnabled() |
boolean |
isPublicKeyVerificationFailedAuth() |
boolean |
isSCPReadWriteEvents() |
boolean |
isSFTPCloseFileBeforeFailedTransferEvents() |
boolean |
isSFTPReadWriteEvents() |
boolean |
isSFTPVersion4Enabled()
Deprecated.
|
boolean |
isSHA1SignaturesSupported() |
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 privateKeyFormat,
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 |
loadSshCertificate(SshCertificate cert) |
void |
removeEventListener(EventListener listener) |
void |
removeSFTPExtensionFactory(SftpExtensionFactory factory) |
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 |
setChannelDataTimeoutSeconds(int channelDataTimeout) |
void |
setChannelFactory(ChannelFactory channelFactory) |
void |
setChannelLimit(int maxChannels)
Set the maximum number of open channels allowed by each client (defaults
to 100).
|
void |
setCipherPreferredPositionCS(String name,
int position) |
void |
setCipherPreferredPositionSC(String name,
int position) |
void |
setCompressionLevel(int compressionLevel)
Set the compression level to use if compression is enabled
|
void |
setConnectionUploadQuota(long perConnectionUploadQuota) |
void |
setDefaultTerminal(String defaultTerminal)
Set the default terminal to execute when the user requests to start a
shell.
|
void |
setDisableSFTPDirChecks(boolean disableSFTPDirChecks) |
void |
setEnableETM(boolean enableETM) |
void |
setExecutorService(ExecutorService executor) |
void |
setFileSystemProvider(FileSystemFactory fileSystemFactory)
Set the
FileSystem for this SSHD
instance. |
void |
setForwardingBufferMaxQueueCount(int forwardingBufferMaxQueueCount) |
void |
setForwardingCallback(ForwardingCallback forwardingCallback)
Set the forwarding callback implementation for this server context.
|
void |
setForwardingPolicy(ForwardingPolicy forwardingPolicy) |
void |
setHttpRedirect(boolean httpRedirect) |
void |
setHttpRedirectUrl(String httpRedirectUrl) |
void |
setIdleAuthenticationTimeoutSeconds(int idleAuthenticationTimeoutSeconds) |
void |
setIdleConnectionTimeoutSeconds(int idleConnectionTimeout)
Inform the context that the connection should be disconnected on session
timeout
|
void |
setIPPolicy(IPPolicy ipPolicy) |
void |
setKeepAliveDataMaxLength(int keepAliveDataMaxLength)
Set the maximum data length for the keep-alive packet.
|
void |
setKeepAliveInterval(int keepAliveInterval)
Set the keep-alive interval (in seconds).
|
void |
setKerberosConfiguration(Configuration kerberosConfiguration)
Set the custom Kerberos configuration.
|
void |
setKerberosDC(String kerberosDC)
Set the Kerberos domain controller address .
|
void |
setKerberosRealm(String kerberosRealm)
Set the realm name to use for GSSAPI Kerberos authentication.
|
void |
setKerberosServicePassword(char[] kerberosServicePassword)
Set the Kerberos service account password.
|
void |
setKerberosServicePrincipal(String kerberosServicePrincipal)
Set the Kerberos service account princial.
|
void |
setKeyExchangeDisabled(boolean keyExchangeDisabled) |
void |
setKeyExchangePacketLimit(int MAX_NUM_PACKETS_BEFORE_REKEY)
This tells the server how many packets to use before a key exchange.
|
void |
setKeyExchangePreferredPosition(String name,
int position) |
void |
setKeyExchangeTransferLimit(int MAX_NUM_BYTES_BEFORE_REKEY)
This limit tells the server when to force a key exchange.
|
void |
setLocale(Locale locale) |
void |
setMacPreferredPositionCS(String name,
int position) |
void |
setMacPreferredPositionSC(String name,
int position) |
void |
setManagedSFTPWindow(boolean managedSFTPWindow)
Deprecated.
|
void |
setMaxAuthentications(int maxAuthentications)
Set the maximum number of failed authentications allowed for each
connection.
|
void |
setMaxConcurrentTransfers(int maxConcurrentTransfers) |
void |
setMaxDHGroupExchangeKeySize(int maxDHGroupExchangeKeySize) |
void |
setMaximumChannelsPerConnection(int maximumChannelsPerConnection) |
void |
setMaximumConnections(int maximumConnections)
Set the maximum number of connections allowed at any one time.
|
void |
setMaximumNumberofAsyncSFTPRequests(int maximumSftpRequests)
Deprecated.
This setting is redundant
|
void |
setMaximumPacketLength(int maximumPacketLength)
Set the maximum supported length of an SSH packet.
|
void |
setMaximumPublicKeyVerificationAttempts(int maximumPublicKeyVerificationAttempts)
Set the number of public keys that a user can verify for public key
authentication.
|
void |
setMaximumSFTPWindowSpace(int maximumSFTPWindowSpace) |
void |
setMaximumSocketsBacklogPerRemotelyForwardedConnection(int maximumSocketsBacklogPerRemotelyForwardedConnection) |
void |
setMaximumUserConnections(int maximumUserConnections)
Set the maximum number of connections a user is allowed at any one time.
|
void |
setMaxSessions(int maxSessions) |
void |
setMaxumumSessionWindowSpace(int maxumumSessionWindowSpace) |
void |
setMessagePolicy(MessagePolicy messagePolicy) |
void |
setMinDHGroupExchangeKeySize(int minDHGroupExchangeKeySize) |
void |
setMinimumRemotePacketSize(int minimumRemotePacketSize) |
void |
setMinimumSFTPWindowSapce(int minimumSFTPWindowSapce)
Deprecated.
|
void |
setMinimumSFTPWindowSpace(int minimumSFTPWindowSapce) |
void |
setNonStandardAlgorithmsEnabled(boolean nonStandardAlgorithmsEnabled) |
void |
setPreferredCipherCC(String[] order)
Set the preferred CS cipher order
|
void |
setPreferredCipherCS(int[] order)
Set the preferred SC cipher order
|
void |
setPreferredCipherCS(String name)
Set the preferred cipher for the Client->Server stream.
|
void |
setPreferredCipherSC(int[] order)
Set the preferred SC cipher order
|
void |
setPreferredCipherSC(String name)
Set the preferred cipher for the Server->Client stream.
|
void |
setPreferredCipherSC(String[] order)
Set the preferred SC cipher order
|
void |
setPreferredCompressionCS(String name)
Set the preferred compression for the Client->Server stream.
|
void |
setPreferredCompressionSC(String name)
Set the preferred compression for the Server->Client stream.
|
void |
setPreferredKeyExchange(String name)
Set the preferred key exchange method.
|
void |
setPreferredKeyExchange(String[] order) |
void |
setPreferredMacCS(int[] order)
Set the preferred CS Mac order
|
void |
setPreferredMacCS(String name)
Set the preferred MAC for the Client->Server stream.
|
void |
setPreferredMacCS(String[] order) |
void |
setPreferredMacSC(int[] order)
Set the preferred SC Mac order
|
void |
setPreferredMacSC(String name)
Set the preferred mac for the Server->Client stream.
|
void |
setPreferredMacSC(String[] order) |
void |
setPreferredPublicKey(String name)
Set the preferred public key algorithm.
|
void |
setPreventDirectoryDuplicateReadsPerChannel(boolean preventDirectorySuplicateReadsPerChannel) |
void |
setPublicKeyAuthenticationVerifier(PublicKeyAuthenticationVerifier verifier) |
void |
setPublicKeyPreferredPosition(String name,
int position) |
void |
setPublicKeyStore(PublicKeyStore publicKeyStore)
For publickey authentication you can optionally provide an alternative
key store implementation.
|
void |
setPublicKeyVerificationIsFailedAuth(boolean publicKeyVerificationIsFailedAuth) |
void |
setRemoteForwardingCancelKillsTunnels(boolean killTunnelsOnRemoteForwardingCancel)
When the user cancels a remote forwarding should active tunnels be
dropped?
|
void |
setRemoteForwardingFactoryImpl(Class<? extends RemoteForwardingFactory> remoteForwardingChannelFactory) |
void |
setRemoteForwardingManagerImpl(Class<? extends RemoteForwardingManager> remoteForwardingManagerImpl) |
void |
setRequiredAuthenticationMethods(int authmethods) |
void |
setRequiredAuthenticationStrategy(RequiredAuthenticationStrategy requiredAuthenticationStrategy) |
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 |
setSFTPCloseFileBeforeFailedTransferEvents(boolean closeFileBeforeFailedTransferEvents) |
void |
setSFTPLongnameDateFormat(String sftpLongnameDateFormat) |
void |
setSFTPLongnameDateFormatWithTime(String sftpLongnameDateFormatWithTime) |
void |
setSFTPReadWriteEvents(boolean sftpReadWriteEvents) |
void |
setSHA1SignaturesSupported(boolean supportSHA1Signatures) |
void |
setShellCommand(Class<? extends ExecutableCommand> shellCommand)
Set an
ExecutableCommand
implementation that provides the default shell. |
void |
setShellPolicy(ShellPolicy shellPolicy) |
void |
setShellPolixy(ShellPolicy shellPolicy)
Deprecated.
|
void |
setSoftwareVersionComments(String softwareVersionComments)
Set the current implementations software/version/comments field that is
used during the SSH protocols negotiation procedure.
|
void |
setSupportedSFTPVersion(int sftpVersion) |
void |
setTooManyConnectionsText(String tooManyConnectionsText) |
void |
setUsernamePolicy(UsernamePolicy usernamePolicy) |
void |
setWelcomeText(String welcomeText) |
void |
setWriteSCPBaseDir(boolean writeSCPBaseDir) |
void |
shutdown() |
ComponentFactory<SshCipher> |
supportedCiphersCS()
Returns a factory implementation that enables configuration of the
available ciphers.
|
ComponentFactory<SshCipher> |
supportedCiphersSC() |
ComponentFactory<SshCompression> |
supportedCompressionsCS()
Get the supported compression algorithms.
|
ComponentFactory<SshCompression> |
supportedCompressionsSC() |
ComponentFactory<SshKeyExchange> |
supportedKeyExchanges()
Get the supported key exchange methods.
|
ComponentFactory<SshHmac> |
supportedMacsCS()
Get the supported message authentication algorithms.
|
ComponentFactory<SshHmac> |
supportedMacsSC() |
ComponentFactory<SshPublicKey> |
supportedPublicKeys() |
ComponentFactory<Subsystem> |
supportedSubsystems()
Deprecated.
No longer used. Subsystems are created by ChannelFactory
|
createConnection, createConnectionImpl, getReceiveBufferSize, getSendBufferSize, getSocketConnectionFactory, getSocketOptionKeepAlive, getSocketOptionReuseAddress, getSocketOptionTcpNoDelay, getSoLinger, getSoLingerTimeout, hasSetSoLinger, setReceiveBufferSize, setSendBufferSize, setSocketConnectionFactory, setSocketHandlerImpl, setSocketOptionKeepAlive, setSocketOptionReuseAddress, setSocketOptionTcpNoDelay, setSoLinger
public static final String CIPHER_TRIPLEDES_CBC
public static final String CIPHER_TRIPLEDES_CTR
public static final String CIPHER_BLOWFISH_CBC
public static final String CIPHER_AES128_CBC
public static final String CIPHER_AES192_CBC
public static final String CIPHER_AES256_CBC
public static final String CIPHER_AES128_CTR
public static final String CIPHER_AES192_CTR
public static final String CIPHER_AES256_CTR
public static final String CIPHER_ARCFOUR
public static final String CIPHER_ARCFOUR_128
public static final String CIPHER_ARCFOUR_256
public static final String CIPHER_AES_GCM_128
public static final String CIPHER_AES_GCM_256
public static final String HMAC_SHA1
public static final String HMAC_SHA1_ETM
public static final String HMAC_SHA1_96
public static final String HMAC_MD5
public static final String HMAC_MD5_ETM
public static final String HMAC_MD5_96
public static final String HMAC_SHA256
public static final String HMAC_SHA256_ETM
public static final String HMAC_SHA256_96
public static final String HMAC_SHA512
public static final String HMAC_SHA512_ETM
public static final String HMAC_SHA512_96
public static final String HMAC_RIPEMD160
public static final String HMAC_RIPEMD160_ETM
public static final String COMPRESSION_NONE
public static final String COMPRESSION_ZLIB
public static final String KEX_DIFFIE_HELLMAN_GROUP1_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256
public static final String KEX_DIFFIE_HELLMAN_GROUP14_SHA256
public static final String KEX_DIFFIE_HELLMAN_GROUP14_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP15_SHA512
public static final String KEX_DIFFIE_HELLMAN_GROUP16_SHA512
public static final String KEX_DIFFIE_HELLMAN_GROUP17_SHA512
public static final String KEX_DIFFIE_HELLMAN_GROUP18_SHA512
public static final String KEX_ECDH_NISPT_256
public static final String KEX_ECDH_NISPT_384
public static final String KEX_ECDH_NISPT_521
public static final String KEX_CURVE_25519_SHA256_LIBSSH_ORG
public static final String KEX_CURVE_25519_SHA256
public static final String KEX_RSA_2048_SHA256
public static final String KEX_RSA_1024_SHA1
public static final String PUBLIC_KEY_SSHDSS
public static final String PUBLIC_KEY_SSHRSA
public static final String PUBLIC_KEY_ECDSA256
public static final String PUBLIC_KEY_ECDSA384
public static final String PUBLIC_KEY_ECDSA521
public static final String PUBLIC_KEY_ED448
public static final String PUBLIC_KEY_ED25519
public static final String PUBLIC_KEY_RSA_SHA256
public static final String PUBLIC_KEY_RSA_SHA512
public static final String PASSWORD_AUTHENTICATION
public static final String PUBLICKEY_AUTHENTICATION
public static final String KEYBOARD_INTERACTIVE_AUTHENTICATION
public static final int ANY
public static final int PUBLIC_KEY
public static final int PASSWORD
public static final int PUBLIC_KEYandPASSWORD
public static final int KEYBOARD_INTERACTIVE
public SshContext() throws IOException
IOException
public SshContext(Daemon daemon, SecurityLevel securityLevel) throws IOException
IOException
public SshContext(Daemon daemon) throws IOException
IOException
public void init(Daemon daemon)
public ProtocolEngine createEngine() throws IOException
ProtocolContext
createEngine
in class ProtocolContext
IOException
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 privateKeyFormat, 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, 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
@Deprecated public static SshKeyPair GenerateKeyFiles(File keyFilename, String type, int bitlength, int privateKeyFormat, int publicKeyFormat) throws IOException, SshException
keyFilename
- type
- bitlength
- privateKeyFormat
- publicKeyFormat
- IOException
SshException
public static SshKeyPair generateKeyFiles(File keyFilename, String type, int bitlength, int privateKeyFormat, int publicKeyFormat, String passphrase) 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 addGlobalRequestHandler(GlobalRequestHandler handler)
public GlobalRequestHandler getGlobalRequestHandler(String requestname)
public Class<? extends RemoteForwardingFactory> getRemoteForwardingFactoryImpl()
public Class<? extends RemoteForwardingManager> getRemoteForwardingManagerImpl()
public void setRemoteForwardingFactoryImpl(Class<? extends RemoteForwardingFactory> remoteForwardingChannelFactory) throws IOException
IOException
public void setRemoteForwardingManagerImpl(Class<? extends RemoteForwardingManager> remoteForwardingManagerImpl) throws IOException
IOException
public void setPublicKeyStore(PublicKeyStore publicKeyStore)
publicKeyStore
- PublicKeyStorepublic String[] getRequiredAuthentications()
public void addRequiredAuthentication(String method)
Set an authentication method as required. You can have multiple required
authentications but by default none are required, although at least one
authentication MUST be performed. For example to require both password
and publickey authentication use the following statements in the
SshDaemon#configure(ConfigurationContext)
method.
context.addRequiredAuthentication(ConfigurationContext.PUBLICKEY_AUTHENTICATION); context.addRequiredAuthentication(ConfigurationContext.PASSWORD_AUTHENTICATION);
method
- Stringpublic String getBannerMessage()
public Daemon getServer()
public String getSFTPCharsetEncoding()
public void setSFTPCharsetEncoding(String sftpCharsetEncoding)
sftpCharsetEncoding
- Stringpublic int getSessionTimeout()
public void setSessionTimeout(int sessionTimeoutSeconds)
sessionTimeoutSeconds
- intpublic void setChannelLimit(int maxChannels)
maxChannels
- public int getChannelLimit()
public int getMaxAuthentications()
public void setMaxAuthentications(int maxAuthentications)
maxAuthentications
- public void setMaximumConnections(int maximumConnections)
maximumConnections
- intpublic int getMaximumConnections()
public void setMaximumUserConnections(int maximumUserConnections)
maximumConnections
- intpublic int getMaximumUserConnections()
public ComponentFactory<SshCipher> supportedCiphersCS()
Returns a factory implementation that enables configuration of the available ciphers.
The standard default ciphers installed are 3DES and Blowfish, however the
J2SSH Maverick API on which this server is based also supports a number
of optional ciphers AES, CAST and Twofish. These can be installed by
adding the sshtools-cipher.jar to your class path and using the
following code within your SSHD
SshDaemon#configure(ConfigurationContext)
method.
// import the cipher package import com.sshtools.cipher.*; // Add AES context.supportedCiphers().add(AES128Cbc.AES128_CBC, AES128Cbc.class); context.supportedCiphers().add(AES192Cbc.AES192_CBC, AES192Cbc.class); context.supportedCiphers().add(AES256Cbc.AES256_CBC, AES256Cbc.class); // Add Twofish - note the 256 bit cipher has two different entries to maintain backwards compatibility context.supportedCiphers().add(Twofish128Cbc.TWOFISH128_CBC, Twofish128Cbc.class); context.supportedCiphers().add(Twofish192Cbc.TWOFISH192_CBC, Twofish192Cbc.class); context.supportedCiphers().add(Twofish256Cbc.TWOFISH256_CBC, Twofish256Cbc.class); context.supportedCiphers().add(Twofish256Cbc.TWOFISH_CBC, Twofish256Cbc.class); // Add CAST context.supportedCiphers().add(CAST128Cbc.CAST128_CBC, CAST128Cbc.class);
public ComponentFactory<SshCipher> supportedCiphersSC()
public String getPreferredCipherCS()
public void setPreferredCipherCS(String name) throws IOException, SshException
Set the preferred cipher for the Client->Server stream.
Use the static fields available within this class (or the com.sshtools.cipher classes) to identify the correct cipher.
context.setPreferredCipherCS(ConfigurationContext.CIPHER_BLOWFISH_CBC);
name
- IOException
- if the cipher is not supportedSshException
public void setBannerMessage(String authenticationBanner)
authenticationBanner
- public String getPreferredCipherSC()
public String getSoftwareVersionComments()
public void setSoftwareVersionComments(String softwareVersionComments)
softwareVersionComments
- public void setPreferredCipherSC(String name) throws IOException, SshException
Set the preferred cipher for the Server->Client stream.
Use the static fields available within this class (or the com.sshtools.cipher classes) to identify the correct cipher.
context.setPreferredCipherSC(ConfigurationContext.CIPHER_BLOWFISH_CBC);
name
- IOException
SshException
public ComponentFactory<SshHmac> supportedMacsCS()
Get the supported message authentication algorithms.
There are no optional MAC algorithms currently available and this method is supplied in preperation for future enhancements.
public ComponentFactory<SshHmac> supportedMacsSC()
public String getPreferredMacCS()
public void setPreferredMacCS(String name) throws IOException, SshException
Set the preferred MAC for the Client->Server stream.
Use the static fields available within this class to identify the correct MAC.
context.setPreferredMacCS(ConfigurationContext.HMAC_MD5);
name
- IOException
SshException
public String getPreferredMacSC()
public void setRemoteForwardingCancelKillsTunnels(boolean killTunnelsOnRemoteForwardingCancel)
killTunnelsOnRemoteForwardingCancel
- booleanpublic boolean getRemoteForwardingCancelKillsTunnels()
public int getMaximumPublicKeyVerificationAttempts()
public void setMaximumPublicKeyVerificationAttempts(int maximumPublicKeyVerificationAttempts)
maximumPublicKeyVerificationAttempts
- intpublic void setPreferredMacSC(String name) throws IOException, SshException
Set the preferred mac for the Server->Client stream.
Use the static fields available within this class to identify the correct MAC.
context.setPreferredMacCS(ConfigurationContext.HMAC_MD5);
name
- IOException
SshException
public ComponentFactory<SshCompression> supportedCompressionsCS()
Get the supported compression algorithms.
There are no optional compression algorithms currently available and this method is supplied in preperation for future enhancements.
public ComponentFactory<SshCompression> supportedCompressionsSC()
public String getPreferredCompressionCS()
public void setPreferredCompressionCS(String name) throws IOException
Set the preferred compression for the Client->Server stream.
It is recommended that you do not set the preferred compression so that the client has control over the compression selection.
name
- IOException
public String getPreferredCompressionSC()
public void setPreferredCompressionSC(String name) throws IOException
Set the preferred compression for the Server->Client stream.
It is recommended that you do not set the preferred compression so that the client has control over the compression selection.
name
- IOException
public ComponentFactory<SshKeyExchange> supportedKeyExchanges()
Get the supported key exchange methods.
There are no optional key exchange algorithms currently available and this method is supplied in preperation for future enhancements.
public String getPreferredKeyExchange()
public void setPreferredKeyExchange(String name) throws IOException, SshException
Set the preferred key exchange method.
There is only one supported key exchange algorithm and as such this method is supplied in preperation for future enhancements.
name
- IOException
SshException
public String getPreferredPublicKey()
public String getSupportedPublicKeys()
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 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 Class<? extends ExecutableCommand> getShellCommand()
ExecutableCommand
implementation that provides the default shell.public void setShellCommand(Class<? extends ExecutableCommand> shellCommand)
ExecutableCommand
implementation that provides the default shell.shellCommand
- public boolean hasPublicKey(String algorithm)
algorithm
- public void setFileSystemProvider(FileSystemFactory fileSystemFactory)
Set the FileSystem
for this SSHD
instance.
This uses a class object rather so that the server can manage the creation of instances of this class.
filesystemProvider
- public FileSystemFactory getFileSystemProvider()
FileSystem
for this SSHD
instance.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 ComponentFactory<Subsystem> supportedSubsystems()
Get the supported Subsystem
's for this SSHD
instance.
If you have implemented a custom subsystem you can use the factory object returned by this method to install the new subsystem.
context.supportedSubsystems().add("mysubsystem", MySubsystem.class);
public void setCompressionLevel(int compressionLevel)
compressionLevel
- intpublic int getCompressionLevel()
public void setAllowDeniedKEX(boolean allowKeyExchangeForDeniedConnection)
public void setRequiredAuthenticationMethods(int authmethods)
public boolean getAllowDeniedKEX()
public int getMaximumSocketsBacklogPerRemotelyForwardedConnection()
public void setMaximumSocketsBacklogPerRemotelyForwardedConnection(int maximumSocketsBacklogPerRemotelyForwardedConnection)
public String getTooManyConnectionsText()
public void setTooManyConnectionsText(String tooManyConnectionsText)
public String getCiphersSC()
public String getCiphersCS()
public String getMacsCS()
public String getMacsSC()
public String getPublicKeys()
public String getKeyExchanges()
public void setPreferredCipherSC(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredCipherSC(String[] order) throws SshException
order
- SshException
public void setPreferredCipherCS(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredCipherCC(String[] order) throws SshException
order
- SshException
public void setPreferredMacSC(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredMacSC(String[] order) throws SshException
order
- SshException
public void setPreferredKeyExchange(String[] order) throws SshException
order
- SshException
public void setPreferredMacCS(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredMacCS(String[] order) throws SshException
SshException
public void setCipherPreferredPositionCS(String name, int position) throws SshException
SshException
public void setCipherPreferredPositionSC(String name, int position) throws SshException
SshException
public void setMacPreferredPositionSC(String name, int position) throws SshException
SshException
public void setMacPreferredPositionCS(String name, int position) throws SshException
SshException
public void setPublicKeyPreferredPosition(String name, int position) throws SshException
SshException
public void setKeyExchangePreferredPosition(String name, int position) throws SshException
SshException
public void setForwardingCallback(ForwardingCallback forwardingCallback)
forwardingCallback
- NNForwardingCallbackpublic ForwardingCallback getForwardingCallback()
public void setMaximumPacketLength(int maximumPacketLength)
maximumPacketLength
- intpublic int getMaximumPacketLength()
public void setKeyExchangeTransferLimit(int MAX_NUM_BYTES_BEFORE_REKEY)
MAX_NUM_BYTES_BEFORE_REKEY
- intpublic void setKeyExchangePacketLimit(int MAX_NUM_PACKETS_BEFORE_REKEY)
MAX_NUM_PACKETS_BEFORE_REKEY
- intpublic int getKeyExchangeTransferLimit()
public int getKeyExchangePacketLimit()
public int getIdleConnectionTimeoutSeconds()
public void setIdleConnectionTimeoutSeconds(int idleConnectionTimeout)
idleConnectionTimeout
- public ComponentFactory<SshPublicKey> supportedPublicKeys()
public int getKeepAliveInterval()
public void setKeepAliveInterval(int keepAliveInterval)
keepAliveInterval
- public int getKeepAliveDataMaxLength()
public void setKeepAliveDataMaxLength(int keepAliveDataMaxLength)
keepAliveDataMaxLength
- public String getKerberosRealm()
Configuration
has been set using
setKerberosConfiguration(Configuration)
.public void setKerberosRealm(String kerberosRealm)
kerberosRealm
- kerberos realmpublic String getKerberosDC()
public void setKerberosDC(String kerberosDC)
kerberosDC
- kerberos domain controllerpublic char[] getKerberosServicePassword()
public void setKerberosServicePassword(char[] kerberosServicePassword)
kerberosServicePassword
- param kerberos service account passwordpublic String getKerberosServicePrincipal()
Configuration
has been set using
setKerberosConfiguration(Configuration)
.public void setKerberosServicePrincipal(String kerberosServicePrincipal)
Configuration
has been set using
setKerberosConfiguration(Configuration)
.kerberosServicePrincipal
- kerberos service account principalpublic Configuration getKerberosConfiguration()
null
.public void setKerberosConfiguration(Configuration kerberosConfiguration)
null
.kerberosConfiguration
- kerberos configurationpublic boolean isAllowZeroLengthFileUpload()
public void setAllowZeroLengthFileUpload(boolean allowZeroLengthFileUpload)
allowZeroLengthFileUpload
- public void setLocale(Locale locale)
public Locale getLocale()
@Deprecated public void enableFIPSMode() throws SshException
SshException
public ExecutorService getExecutorService()
getExecutorService
in interface ExecutorServiceProvider
getExecutorService
in class ProtocolContext
public void setExecutorService(ExecutorService executor)
setExecutorService
in interface ExecutorServiceProvider
public void setMaxConcurrentTransfers(int maxConcurrentTransfers)
public int getMaxConcurrentTransfers()
public void setPublicKeyVerificationIsFailedAuth(boolean publicKeyVerificationIsFailedAuth)
public boolean isPublicKeyVerificationFailedAuth()
@Deprecated public void enableSFTPVersion4()
public void setSupportedSFTPVersion(int sftpVersion)
public int getSFTPVersion()
@Deprecated public boolean isSFTPVersion4Enabled()
public void shutdown()
shutdown
in class ProtocolContext
public ByteBufferPool getByteBufferPool()
public void loadSshCertificate(File keyFile, String passphrase, File certFile) throws IOException, InvalidPassphraseException
public void loadSshCertificate(SshCertificate cert) throws IOException, InvalidPassphraseException
public AuthenticationMechanismFactory getAuthenticationMechanismFactory()
public void setAuthenicationMechanismFactory(AuthenticationMechanismFactory authFactory)
public int getForwardingBufferMaxQueueCount()
public void setForwardingBufferMaxQueueCount(int forwardingBufferMaxQueueCount)
public String getWelcomeText()
public void setWelcomeText(String welcomeText)
public PublicKeyAuthenticationVerifier getPublicKeyAuthenticationVerifier()
public void setPublicKeyAuthenticationVerifier(PublicKeyAuthenticationVerifier verifier)
public ShellPolicy getShellPolicy()
@Deprecated public void setShellPolixy(ShellPolicy shellPolicy)
public void setShellPolicy(ShellPolicy shellPolicy)
public IPPolicy getIPPolicy()
public void setIPPolicy(IPPolicy ipPolicy)
public ForwardingPolicy getForwardingPolicy()
public void setForwardingPolicy(ForwardingPolicy forwardingPolicy)
public DaemonContext getDaemonContext()
public ChannelFactory getChannelFactory()
public void setChannelFactory(ChannelFactory channelFactory)
public void setConnectionUploadQuota(long perConnectionUploadQuota)
public long getConnectionUploadQuota()
public int getIdleAuthenticationTimeoutSeconds()
public void setIdleAuthenticationTimeoutSeconds(int idleAuthenticationTimeoutSeconds)
public int getMinDHGroupExchangeKeySize()
public void setMinDHGroupExchangeKeySize(int minDHGroupExchangeKeySize)
public int getMaxDHGroupExchangeKeySize()
public void setMaxDHGroupExchangeKeySize(int maxDHGroupExchangeKeySize)
public void setSFTPReadWriteEvents(boolean sftpReadWriteEvents)
public boolean isSFTPReadWriteEvents()
public void setSCPReadWriteEvents(boolean scpReadWriteEvents)
public boolean isSCPReadWriteEvents()
public String getSFTPLongnameDateFormat()
public String getSFTPLongnameDateFormatWithTime()
public void setSFTPLongnameDateFormat(String sftpLongnameDateFormat)
public void setSFTPLongnameDateFormatWithTime(String sftpLongnameDateFormatWithTime)
public int getChannelDataTimeoutSeconds()
public void setChannelDataTimeoutSeconds(int channelDataTimeout)
public void addEventListener(EventListener listener)
public void removeEventListener(EventListener listener)
public List<EventListener> getEventListeners()
@Deprecated public int getMaximumNumberOfAsyncSFTPRequests()
@Deprecated public void setMaximumNumberofAsyncSFTPRequests(int maximumSftpRequests)
maximumSftpRequests
- public RequiredAuthenticationStrategy getRequiredAuthenticationStrategy()
public void setRequiredAuthenticationStrategy(RequiredAuthenticationStrategy requiredAuthenticationStrategy)
public int getMaximumSFTPWindowSpace()
public void setMaximumSFTPWindowSpace(int maximumSFTPWindowSpace)
public int getMaxumumSessionWindowSpace()
public int getMinimumSFTPWindowSapce()
@Deprecated public void setMinimumSFTPWindowSapce(int minimumSFTPWindowSapce)
public void setMinimumSFTPWindowSpace(int minimumSFTPWindowSapce)
public void setMaxumumSessionWindowSpace(int maxumumSessionWindowSpace)
@Deprecated public boolean isManagedSFTPWindow()
@Deprecated public void setManagedSFTPWindow(boolean managedSFTPWindow)
public void addSFTPExtensionFactory(SftpExtensionFactory factory)
public void removeSFTPExtensionFactory(SftpExtensionFactory factory)
public SftpExtension getSFTPExtension(String requestName)
public List<SftpExtensionFactory> getSFTPExtensionFactories()
public boolean isHttpRedirect()
public void setHttpRedirect(boolean httpRedirect)
public String getHttpRedirectUrl()
public void setHttpRedirectUrl(String httpRedirectUrl)
public boolean isKeyExchangeDisabled()
public void setKeyExchangeDisabled(boolean keyExchangeDisabled)
public boolean isSFTPCloseFileBeforeFailedTransferEvents()
public void setSFTPCloseFileBeforeFailedTransferEvents(boolean closeFileBeforeFailedTransferEvents)
public int getMaximumChannelsPerConnection()
public void setMaximumChannelsPerConnection(int maximumChannelsPerConnection)
public int getMaxSessions()
public void setMaxSessions(int maxSessions)
public boolean getWriteSCPBaseDir()
public void setWriteSCPBaseDir(boolean writeSCPBaseDir)
public boolean getDisableSFTPDirChecks()
public void setDisableSFTPDirChecks(boolean disableSFTPDirChecks)
public int getMinimumRemotePacketSize()
public void setMinimumRemotePacketSize(int minimumRemotePacketSize)
public boolean isEnableETM()
public SecurityLevel getSecurityLevel()
public boolean isNonStandardAlgorithmsEnabled()
public void setEnableETM(boolean enableETM)
public void setNonStandardAlgorithmsEnabled(boolean nonStandardAlgorithmsEnabled)
public int getConnections()
public int incrementConnections()
public int decrementConnections()
public LoadBalancerPolicy getLoadBalancerPolicy()
public MessagePolicy getMessagePolicy()
public void setMessagePolicy(MessagePolicy messagePolicy)
public void setSHA1SignaturesSupported(boolean supportSHA1Signatures)
public boolean isSHA1SignaturesSupported()
public UsernamePolicy getUsernamePolicy()
public void setUsernamePolicy(UsernamePolicy usernamePolicy)
public boolean getPreventDirectoryDuplicateReadsPerChannel()
public void setPreventDirectoryDuplicateReadsPerChannel(boolean preventDirectorySuplicateReadsPerChannel)
Copyright © 2024. All rights reserved.