public class SshServerContext
extends com.sshtools.synergy.ssh.SshContext
byteBufferPool, CIPHER_AES_GCM_128, CIPHER_AES_GCM_256, 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, componentManager, COMPRESSION_NONE, COMPRESSION_ZLIB, compressionLevel, compressionsCS, compressionsSC, daemon, executor, 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_ECDH_NISTP_256, KEX_DIFFIE_HELLMAN_ECDH_NISTP_384, KEX_DIFFIE_HELLMAN_ECDH_NISTP_521, KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA1, KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256, KEX_DIFFIE_HELLMAN_GROUP1_SHA1, KEX_DIFFIE_HELLMAN_GROUP14_SHA1, KEX_DIFFIE_HELLMAN_GROUP14_SHA256, KEX_DIFFIE_HELLMAN_GROUP15_SHA512, KEX_DIFFIE_HELLMAN_GROUP16_SHA512, KEX_DIFFIE_HELLMAN_GROUP17_SHA512, KEX_DIFFIE_HELLMAN_GROUP18_SHA512, KEYBOARD_INTERACTIVE_AUTHENTICATION, keyExchanges, killTunnelsOnRemoteForwardingCancel, locale, macCS, macSC, MAX_NUM_BYTES_BEFORE_REKEY, MAX_NUM_PACKETS_BEFORE_REKEY, maxChannels, maxDHGroupExchangeKeySize, maximumPacketLength, maximumSocketsBacklogPerRemotelyForwardedConnection, minDHGroupExchangeKeySize, PASSWORD_AUTHENTICATION, prefCipherCS, prefCipherSC, prefCompressionCS, prefCompressionSC, preferredDHGroupExchangeKeySize, prefKeyExchange, prefMacCS, prefMacSC, prefPublicKey, PUBLIC_KEY_ECDSA_SHA2_NISPTP_256, PUBLIC_KEY_ECDSA_SHA2_NISPTP_384, PUBLIC_KEY_ECDSA_SHA2_NISPTP_521, PUBLIC_KEY_ED25519, PUBLIC_KEY_RSA_SHA256, PUBLIC_KEY_RSA_SHA512, PUBLIC_KEY_SSHDSS, PUBLIC_KEY_SSHRSA, PUBLICKEY_AUTHENTICATION, publicKeys, sendIgnorePacketOnIdle, socketConnectionFactory, softwareVersionComments
Constructor and Description |
---|
SshServerContext(com.sshtools.synergy.nio.SshEngine engine) |
SshServerContext(com.sshtools.synergy.nio.SshEngine engine,
com.sshtools.common.ssh.components.ComponentManager componentManager) |
SshServerContext(com.sshtools.synergy.nio.SshEngine engine,
com.sshtools.common.ssh.components.ComponentManager componentManager,
com.sshtools.common.ssh.SecurityLevel securityLevel) |
SshServerContext(com.sshtools.synergy.nio.SshEngine engine,
com.sshtools.common.ssh.SecurityLevel securityLevel) |
Modifier and Type | Method and Description |
---|---|
void |
addGlobalRequestHandler(com.sshtools.synergy.ssh.GlobalRequestHandler<SshServerContext> handler) |
void |
addHostKey(com.sshtools.common.ssh.components.SshKeyPair keyPair)
Add a host key to the configuration.
|
void |
addHostKeys(java.util.Collection<com.sshtools.common.ssh.components.SshKeyPair> keys)
Add a collection of host keys.
|
void |
addStateListener(ServerConnectionStateListener stateListener) |
protected void |
configureKeyExchanges()
Build the key exchanges available in this context.
|
com.sshtools.synergy.nio.ProtocolEngine |
createEngine(com.sshtools.synergy.nio.ConnectRequestFuture connectFuture) |
static com.sshtools.common.ssh.components.SshKeyPair |
generateKey(java.lang.String type,
int bitLength)
Generate a key pair.
|
static com.sshtools.common.ssh.components.SshKeyPair |
generateKeyFiles(java.io.File keyFilename,
java.lang.String type,
int bitlength,
int publicKeyFormat)
Generate a public and private key pair, save them to keyFilename and
keyFilename.pub, return the key pair
|
void |
generateTemporaryHostKey(java.lang.String algorithm,
int bitlength) |
com.sshtools.common.auth.AuthenticationMechanismFactory<SshServerContext> |
getAuthenticationMechanismFactory()
Get the
AuthenticationMechanismFactory for this context. |
com.sshtools.synergy.ssh.ChannelFactory<SshServerContext> |
getChannelFactory() |
com.sshtools.synergy.ssh.ConnectionManager<SshServerContext> |
getConnectionManager() |
com.sshtools.synergy.ssh.ForwardingManager<SshServerContext> |
getForwardingManager() |
com.sshtools.synergy.ssh.GlobalRequestHandler<SshServerContext> |
getGlobalRequestHandler(java.lang.String name) |
com.sshtools.common.ssh.components.SshKeyPair |
getHostKey(java.lang.String algorithm)
Get the host key for a given algorithm.
|
com.sshtools.common.ssh.components.SshKeyPair[] |
getHostKeys()
Get all the hosts keys.
|
int |
getMaxDHGroupExchangeKeySize()
Get the maximum group size supported in
diffie-hellman-group-exchange key exchange methods. |
java.lang.String |
getPreferredPublicKey()
Get the currently preferred public key algorithm.
|
java.util.Collection<ServerConnectionStateListener> |
getStateListeners() |
java.lang.String |
getSupportedPublicKeys()
Returns a comma delimited string containing installed public key types.
|
boolean |
hasPublicKey(java.lang.String algorithm)
Determine if the server has a host key configured.
|
boolean |
isEnsureGracefulDisconnect()
If a problem occurs, or a connection is denied, for example if maximum connections threshold
has been reached, this setting determines if the connection is allowed to proceed through
key exchange so that the user is returned a suitable error.
|
boolean |
isForceServerPreferences()
Is the server wanting to control key exchange
#setServerControllerKeyExchange() |
void |
loadHostKey(java.io.InputStream in)
Load a host key from an InputStream.
|
void |
loadHostKey(java.io.InputStream in,
java.lang.String passPhrase)
Load a host key from an InputStream.
|
com.sshtools.common.ssh.components.SshKeyPair |
loadKey(java.io.File key,
java.lang.String passphrase)
Load a key pair from a File
|
com.sshtools.common.ssh.components.SshKeyPair |
loadKey(java.io.InputStream in,
java.lang.String passphrase)
Load a key pair from an InputStream.
|
com.sshtools.common.ssh.components.SshKeyPair |
loadOrGenerateHostKey(java.io.File key,
java.lang.String type,
int bitlength)
Load a host key from file, if the file does not exist then generate the
key.
|
com.sshtools.common.ssh.components.SshKeyPair |
loadOrGenerateHostKey(java.io.File key,
java.lang.String type,
int bitlength,
int publicKeyFormat,
java.lang.String passPhrase)
Load a host key from file, if the file does not exist then generate the
key.
|
com.sshtools.common.ssh.components.SshKeyPair |
loadOrGenerateHostKey(java.io.File key,
java.lang.String type,
int bitlength,
java.lang.String passPhrase)
Load a host key from a file, if it does not exist, generate it.
|
void |
loadSshCertificate(java.io.File keyFile,
java.lang.String passphrase,
java.io.File certFile)
This method loads an OpenSSH certificate file for use as a host key.
|
void |
loadSshCertificate(com.sshtools.common.ssh.components.SshCertificate cert) |
void |
setAuthenicationMechanismFactory(com.sshtools.common.auth.AuthenticationMechanismFactory<SshServerContext> authFactory)
Set the
AuthenticationMechanismFactory for this context. |
void |
setChannelFactory(com.sshtools.synergy.ssh.ChannelFactory<SshServerContext> channelFactory) |
void |
setConnectionManager(com.sshtools.synergy.ssh.ConnectionManager<SshServerContext> connectionManager) |
void |
setEnsureGracefulDisconnect(boolean ensureGracefulDisconnect)
If a problem occurs, or a connection is denied, for example if maximum connections threshold
has been reached, this setting determines if the connection is allowed to proceed through
key exchange so that the user is returned a suitable error.
|
void |
setForceServerPreferences(boolean serverControlledKeyExchange)
When
true the server will delay it's key exchange initialisation
until it has received the client's initialisation packet. |
void |
setForwardingManager(com.sshtools.synergy.ssh.ForwardingManager<SshServerContext> forwardingManager) |
void |
setMaxDHGroupExchangeSize(int maxDHGroupSize)
Set the maximum group size supported in
diffie-hellman-group-exchange key exchange methods. |
void |
setPreferredPublicKey(java.lang.String name)
Set the preferred public key algorithm.
|
addOperationListener, enableFIPSMode, getAuthenticatedFuture, getByteBufferPool, getChannelLimit, getCiphersCS, getCiphersSC, getComponentManager, getCompressionLevel, getDaemonContext, getEngine, getExecutorListeners, getExecutorService, getForwardingPolicy, getHttpRedirectUrl, getIdleAuthenticationTimeoutSeconds, getIdleConnectionTimeoutSeconds, getKeepAliveDataMaxLength, getKeepAliveInterval, getKeyExchangePacketLimit, getKeyExchanges, getKeyExchangeTransferLimit, getLocale, getMacsCS, getMacsSC, getMaximumPacketLength, getMaximumSocketsBacklogPerRemotelyForwardedConnection, getMinDHGroupExchangeKeySize, getPolicy, getPolicy, getPreferredCipherCS, getPreferredCipherSC, getPreferredCompressionCS, getPreferredCompressionSC, getPreferredDHGroupExchangeKeySize, getPreferredKeyExchange, getPreferredMacCS, getPreferredMacSC, getPublicKeys, getRemoteForwardingCancelKillsTunnels, getSocketConnectionFactory, getSoftwareVersionComments, hasPolicy, init, isHttpRedirect, isSendIgnorePacketOnIdle, listPublicKeys, removeOperationListener, setChannelLimit, setCipherPreferredPositionCS, setCipherPreferredPositionSC, setCompressionLevel, setHttpRedirect, setHttpRedirectUrl, setIdleAuthenticationTimeoutSeconds, setIdleConnectionTimeoutSeconds, setKeepAliveDataMaxLength, setKeepAliveInterval, setKeyExchangePacketLimit, setKeyExchangePreferredPosition, setKeyExchangeTransferLimit, setLocale, setMacPreferredPositionCS, setMacPreferredPositionSC, setMaxDHGroupExchangeKeySize, setMaximumPacketLength, setMaximumSocketsBacklogPerRemotelyForwardedConnection, setMinDHGroupExchangeKeySize, setPolicy, setPreferredCipherCS, setPreferredCipherCS, setPreferredCipherCS, setPreferredCipherSC, setPreferredCipherSC, setPreferredCipherSC, setPreferredCompressionCS, setPreferredCompressionSC, setPreferredDHGroupExchangeKeySize, setPreferredKeyExchange, setPreferredKeyExchange, setPreferredMacCS, setPreferredMacCS, setPreferredMacCS, setPreferredMacSC, setPreferredMacSC, setPreferredMacSC, setPublicKeyPreferredPosition, setRemoteForwardingCancelKillsTunnels, setSendIgnorePacketOnIdle, setSocketConnectionFactory, setSoftwareVersionComments, shutdown, supportedCiphersCS, supportedCiphersSC, supportedCompressionsCS, supportedCompressionsSC, supportedKeyExchanges, supportedMacsCS, supportedMacsSC, supportedPublicKeys
enableHTTPProxy, enableHTTPProxy, enableHTTPProxy, enableHTTPProxy, enableSocks4Proxy, enableSocks5Proxy, getOptionalHeaders, getProxyHostname, getProxyPassword, getProxyPort, getProxyType, getProxyUsername, getReceiveBufferSize, getSendBufferSize, getSocketOptionKeepAlive, getSocketOptionReuseAddress, getSocketOptionTcpNoDelay, getUserAgent, isProxyEnabled, isResolveLocally, setReceiveBufferSize, setSendBufferSize, setSocketOptionKeepAlive, setSocketOptionReuseAddress, setSocketOptionTcpNoDelay
public SshServerContext(com.sshtools.synergy.nio.SshEngine engine) throws java.io.IOException, com.sshtools.common.ssh.SshException
java.io.IOException
com.sshtools.common.ssh.SshException
public SshServerContext(com.sshtools.synergy.nio.SshEngine engine, com.sshtools.common.ssh.components.ComponentManager componentManager) throws java.io.IOException, com.sshtools.common.ssh.SshException
java.io.IOException
com.sshtools.common.ssh.SshException
public SshServerContext(com.sshtools.synergy.nio.SshEngine engine, com.sshtools.common.ssh.components.ComponentManager componentManager, com.sshtools.common.ssh.SecurityLevel securityLevel) throws java.io.IOException, com.sshtools.common.ssh.SshException
java.io.IOException
com.sshtools.common.ssh.SshException
public SshServerContext(com.sshtools.synergy.nio.SshEngine engine, com.sshtools.common.ssh.SecurityLevel securityLevel) throws java.io.IOException, com.sshtools.common.ssh.SshException
java.io.IOException
com.sshtools.common.ssh.SshException
public com.sshtools.synergy.ssh.ConnectionManager<SshServerContext> getConnectionManager()
getConnectionManager
in class com.sshtools.synergy.ssh.SshContext
public void setConnectionManager(com.sshtools.synergy.ssh.ConnectionManager<SshServerContext> connectionManager)
public com.sshtools.synergy.nio.ProtocolEngine createEngine(com.sshtools.synergy.nio.ConnectRequestFuture connectFuture) throws java.io.IOException
createEngine
in class com.sshtools.synergy.ssh.SshContext
java.io.IOException
public void addStateListener(ServerConnectionStateListener stateListener)
public java.util.Collection<ServerConnectionStateListener> getStateListeners()
public void addGlobalRequestHandler(com.sshtools.synergy.ssh.GlobalRequestHandler<SshServerContext> handler)
public com.sshtools.synergy.ssh.GlobalRequestHandler<SshServerContext> getGlobalRequestHandler(java.lang.String name)
getGlobalRequestHandler
in class com.sshtools.synergy.ssh.SshContext
public java.lang.String getPreferredPublicKey()
getPreferredPublicKey
in class com.sshtools.synergy.ssh.SshContext
public java.lang.String getSupportedPublicKeys()
getSupportedPublicKeys
in class com.sshtools.synergy.ssh.SshContext
public void setPreferredPublicKey(java.lang.String name) throws java.io.IOException, com.sshtools.common.ssh.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
- java.io.IOException
com.sshtools.common.ssh.SshException
public com.sshtools.common.ssh.components.SshKeyPair[] getHostKeys()
public com.sshtools.common.ssh.components.SshKeyPair getHostKey(java.lang.String algorithm) throws java.io.IOException
algorithm
- java.io.IOException
public void addHostKey(com.sshtools.common.ssh.components.SshKeyPair keyPair) throws java.io.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
- java.io.IOException
public void addHostKeys(java.util.Collection<com.sshtools.common.ssh.components.SshKeyPair> keys) throws java.io.IOException
keys
- java.io.IOException
public void generateTemporaryHostKey(java.lang.String algorithm, int bitlength) throws java.io.IOException, com.sshtools.common.ssh.SshException
java.io.IOException
com.sshtools.common.ssh.SshException
public com.sshtools.synergy.ssh.ChannelFactory<SshServerContext> getChannelFactory()
getChannelFactory
in class com.sshtools.synergy.ssh.SshContext
public void setChannelFactory(com.sshtools.synergy.ssh.ChannelFactory<SshServerContext> channelFactory)
public com.sshtools.synergy.ssh.ForwardingManager<SshServerContext> getForwardingManager()
getForwardingManager
in class com.sshtools.synergy.ssh.SshContext
public void setForwardingManager(com.sshtools.synergy.ssh.ForwardingManager<SshServerContext> forwardingManager)
public boolean hasPublicKey(java.lang.String algorithm)
algorithm
- public com.sshtools.common.ssh.components.SshKeyPair loadOrGenerateHostKey(java.io.File key, java.lang.String type, int bitlength) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException, com.sshtools.common.ssh.SshException
key
- type
- bitlength
- java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
com.sshtools.common.ssh.SshException
public com.sshtools.common.ssh.components.SshKeyPair loadOrGenerateHostKey(java.io.File key, java.lang.String type, int bitlength, java.lang.String passPhrase) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException, com.sshtools.common.ssh.SshException
key
- type
- bitlength
- passPhrase
- java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
com.sshtools.common.ssh.SshException
public void loadHostKey(java.io.InputStream in) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException, com.sshtools.common.ssh.SshException
in
- type
- bitlength
- java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
com.sshtools.common.ssh.SshException
public com.sshtools.common.ssh.components.SshKeyPair loadOrGenerateHostKey(java.io.File key, java.lang.String type, int bitlength, int publicKeyFormat, java.lang.String passPhrase) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException, com.sshtools.common.ssh.SshException
key
- type
- bitlength
- publicKeyFormat
- passPhrase
- java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
com.sshtools.common.ssh.SshException
public void loadHostKey(java.io.InputStream in, java.lang.String passPhrase) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException, com.sshtools.common.ssh.SshException
in
- type
- bitlength
- privateKeyFormat
- publicKeyFormat
- passPhrase
- java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
com.sshtools.common.ssh.SshException
public com.sshtools.common.ssh.components.SshKeyPair loadKey(java.io.File key, java.lang.String passphrase) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException
key
- passphrase
- java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
public com.sshtools.common.ssh.components.SshKeyPair loadKey(java.io.InputStream in, java.lang.String passphrase) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException
in
- passphrase
- java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
public static com.sshtools.common.ssh.components.SshKeyPair generateKeyFiles(java.io.File keyFilename, java.lang.String type, int bitlength, int publicKeyFormat) throws java.io.IOException, com.sshtools.common.ssh.SshException
keyFilename
- type
- bitlength
- privateKeyFormat
- publicKeyFormat
- java.io.IOException
com.sshtools.common.ssh.SshException
public static com.sshtools.common.ssh.components.SshKeyPair generateKey(java.lang.String type, int bitLength) throws java.io.IOException, com.sshtools.common.ssh.SshException
type
- bitLength
- java.io.IOException
com.sshtools.common.ssh.SshException
public void loadSshCertificate(java.io.File keyFile, java.lang.String passphrase, java.io.File certFile) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException
keyFile
- passphrase
- certFile
- java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
public void loadSshCertificate(com.sshtools.common.ssh.components.SshCertificate cert) throws java.io.IOException, com.sshtools.common.publickey.InvalidPassphraseException
java.io.IOException
com.sshtools.common.publickey.InvalidPassphraseException
public void setAuthenicationMechanismFactory(com.sshtools.common.auth.AuthenticationMechanismFactory<SshServerContext> authFactory)
AuthenticationMechanismFactory
for this context.authFactory
- public com.sshtools.common.auth.AuthenticationMechanismFactory<SshServerContext> getAuthenticationMechanismFactory()
AuthenticationMechanismFactory
for this context.public boolean isEnsureGracefulDisconnect()
public void setEnsureGracefulDisconnect(boolean ensureGracefulDisconnect)
ensureGracefulDisconnect
- protected void configureKeyExchanges()
configureKeyExchanges
in class com.sshtools.synergy.ssh.SshContext
public void setMaxDHGroupExchangeSize(int maxDHGroupSize)
diffie-hellman-group-exchange
key exchange methods.public int getMaxDHGroupExchangeKeySize()
diffie-hellman-group-exchange
key exchange methods.getMaxDHGroupExchangeKeySize
in class com.sshtools.synergy.ssh.SshContext
public boolean isForceServerPreferences()
#setServerControllerKeyExchange()
public void setForceServerPreferences(boolean serverControlledKeyExchange)
true
the server will delay it's key exchange initialisation
until it has received the client's initialisation packet. This allows the
server to control what algorithms are selected during key exchange by limiting
its own set of algorithms to only those it wants to support. In effect, allowing
the server to control the output of key exchange.serverControlledKeyExchange
- Copyright © 2022. All rights reserved.