public class Ssh2Context extends Object implements SshContext
This class implements SshContextto provide SSH2 connection configuration through the SshConnector class.
To configure an authentication banner for SSH2 connections see BannerDisplay.
The preferred message authentication algorithm for each data stream can be set using:
Once further cipher, public key and compression algorithms have been implemented the same process will apply.SshConnector con = SshConnector.getInstance(); Ssh2Context context = (Ssh2Context) con.getContext(SshConnector.SSH2); context.setPreferredMacCS(Ssh2Context.HMAC_MD5); // Client->Server data stream context.setPreferredMacSC(Ssh2Context.HMAC_MD5); // Server->Client data stream
| Constructor and Description |
|---|
Ssh2Context()
Contructs a default context
|
Ssh2Context(SecurityPolicy securityPolicy) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowHostKeyUpdates()
Accept host key updates from remote server.
|
void |
configureSecurityLevel(SecurityLevel securityLevel) |
void |
disableCompression() |
void |
disableETM() |
void |
disableNonStandardAlgorithms() |
void |
enableCompression() |
void |
enableETM() |
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 |
enableNonStandardAlgorithms() |
BannerDisplay |
getBannerDisplay()
Get the contexts banner display
|
int |
getChannelLimit()
Get the maximum number of channels that are allowed open at any one time.
|
String |
getCiphersCS()
Get the ciphers for the Client->Server stream.
|
String |
getCiphersSC()
Get the ciphers for the Server->Client stream.
|
int |
getDHGroupExchangeKeySize() |
ExecutorService |
getExecutorService() |
MaverickCallbackHandler |
getGssCallback() |
HostKeyVerification |
getHostKeyVerification()
Get the host key verification implementation
|
int |
getIdleAuthenticationTimeoutSeconds() |
int |
getIdleConnectionTimeoutSeconds() |
int |
getKeepAliveMaxDataLength() |
String |
getKeyExchanges()
Get the ciphers for the Server->Client stream.
|
String |
getMacsCS()
Get the ciphers for the Client->Server stream.
|
String |
getMacsSC()
Get the ciphers for the Server->Client stream.
|
int |
getMaxDHGroupSize() |
int |
getMaximumPacketLength()
Get the maximim packet size supported by the transport layer.
|
int |
getMaxNumBytesBeforeReKey() |
int |
getMaxNumPacketsBeforeReKey() |
int |
getMessageTimeout() |
int |
getMinDHGroupSize() |
int |
getPartialMessageTimeout()
Deprecated.
No longer used. Use getSocketTimeout instead.
|
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.
|
String |
getPublicKeys()
Get the ciphers for the Server->Client stream.
|
SecurityPolicy |
getSecurityPolicy() |
int |
getSessionMaxPacketSize() |
int |
getSessionMaxWindowSpace() |
int |
getSftpMaxPacketSize() |
int |
getSftpMaxWindowSpace() |
String |
getSFTPProvider()
Get the path to the SFTP provider.
|
int |
getSocketTimeout() |
boolean |
getTemporaryValue(String name,
boolean defaultValue) |
String |
getTemporaryValue(String name,
String defaultValue) |
byte[] |
getX11AuthenticationCookie()
Get a fake random cookie for X11 authentication
|
String |
getX11Display()
Get the currently configured XDisplay setting which will be null if no
display is currently set.
|
byte[] |
getX11RealCookie()
Get the real X11 authentication cookie, if not cookie has been set the
fake cookie will be returned.
|
ForwardingRequestListener |
getX11RequestListener()
Get the X11 forwarding request listener.
|
boolean |
isDHGroupExchangeBackwardsCompatible() |
boolean |
isEnableETM() |
boolean |
isKeyReExchangeDisabled() |
boolean |
isLimitPublicKeysToKnownHosts() |
boolean |
isNonStandardAlgorithmsEnabled() |
boolean |
isPreferKeyboardInteractiveOverPassword() |
boolean |
isSendIgnorePacketOnIdle() |
boolean |
isSHA1SignaturesSupported()
Option to disable SHA1 signatures on RSA keys.
|
boolean |
isTreatIdleConnectionAsError() |
boolean |
isTriedBackwardsCompatibility()
Deprecated.
|
boolean |
isTriedMinimalKeyExchangePacket()
Deprecated.
|
void |
setAllowHostKeyUpdates(boolean value)
Tell the client to accept host key updates from the server
|
void |
setBannerDisplay(BannerDisplay bannerdisplay)
Set a banner display for callback of authentication banners
|
void |
setChannelLimit(int maxChannels)
Set the maximum number of channels that are allowed open at any one time.
|
void |
setCipherPreferredPositionCS(String name,
int position) |
void |
setCipherPreferredPositionSC(String name,
int position) |
void |
setDHGroupExchangeBackwardsCompatible(boolean dhGroupExchangeBackwardCompatible) |
void |
setDHGroupExchangeKeySize(int dhGroupExchangeKeySize) |
void |
setExecutorService(ExecutorService executor) |
void |
setGssCallback(MaverickCallbackHandler gsscall) |
void |
setHostKeyVerification(HostKeyVerification verify)
Set the host key verification implementation
|
void |
setIdleAuthenticationTimeoutSeconds(int idleAuthenticationTimeoutSeconds) |
void |
setIdleConnectionTimeoutSeconds(int idleConnectionTimeoutSeconds) |
void |
setKeepAliveMaxDataLength(int keepAliveMaxDataLength) |
void |
setKeyExchangePreferredPosition(String name,
int position) |
void |
setKeyReExchangeDisabled(boolean keyReExchangeDisabled) |
void |
setLimitPublicKeysToKnownHosts(boolean limitPublicKeysToKnownHosts) |
void |
setMacPreferredPositionCS(String name,
int position) |
void |
setMacPreferredPositionSC(String name,
int position) |
void |
setMaxDHGroupSize(int maxDHGroupSize) |
void |
setMaximumPacketLength(int maxPacketLength)
Set the maximum packet size supported by the transport layer.
|
void |
setMaxNumBytesBeforeReKey(int maxNumBytesBeforeReKey) |
void |
setMaxNumPacketsBeforeReKey(int maxNumPacketsBeforeReKey) |
void |
setMessageTimeout(int messageTimeout) |
void |
setMinDHGroupSize(int minDHGroupSize) |
void |
setPartialMessageTimeout(int partialMessageTimeout)
Deprecated.
No longer used. Use setSocketTimeout.
|
void |
setPreferKeyboardInteractiveOverPassword(boolean preferKeyboardInteractiveOverPassword) |
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 |
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 |
setPreferredMacCS(int[] order)
Set the preferred CS Mac order
|
void |
setPreferredMacCS(String name)
Set the preferred mac for the Client->Server stream.
|
void |
setPreferredMacSC(int[] order)
Set the preferred SC Mac order
|
void |
setPreferredMacSC(String name)
Set the preferred mac for the Server->Client stream.
|
void |
setPreferredPublicKey(String name)
Set the preferred public key algorithm.
|
void |
setPublicKeyPreferredPosition(String name,
int position) |
void |
setSendIgnorePacketOnIdle(boolean sendIgnorePacketOnIdle) |
void |
setSessionMaxPacketSize(int sessionMaxPacketSize) |
void |
setSessionMaxWindowSpace(int sessionMaxWindowSpace) |
void |
setSftpMaxPacketSize(int sftpMaxPacketSize) |
void |
setSftpMaxWindowSpace(int sftpMaxWindowSpace) |
void |
setSFTPProvider(String sftpProvider)
Set the path to the SFTP provider.
|
void |
setSHA1SignaturesSupported(boolean supportSHA1Signatures)
Option to disable SHA1 signatures on RSA keys.
|
void |
setSocketTimeout(int socketTimeout) |
void |
setTemporaryValue(String name,
boolean value) |
void |
setTemporaryValue(String name,
String value) |
void |
setTreatIdleConnectionAsError(boolean treatIdleConnectionAsError) |
void |
setTriedBackwardsCompatibility(boolean triedBackwardsCompatibility)
Deprecated.
|
void |
setTriedMinimalKeyExchangePacket(boolean triedMinimalKeyExchangePacket)
Deprecated.
|
void |
setX11AuthenticationCookie(byte[] x11FakeCookie)
Set the fake cookie used for X11 authentication
|
void |
setX11Display(String xDisplay)
Set the DISPLAY variable for the SSH connection.
|
void |
setX11RealCookie(byte[] x11RealCookie)
Sets the real X11 authentication cookie which can be obtained from the
users $HOME/.Xauthority file.
|
void |
setX11RequestListener(ForwardingRequestListener x11Listener)
Set the listener to which X11 forwarding requests will be processed.
|
ComponentFactory<SshCipher> |
supportedCiphersCS() |
ComponentFactory<SshCipher> |
supportedCiphersSC()
Returns this context's supported cipher algorithms.
|
ComponentFactory<SshCompression> |
supportedCompressionsCS()
Get this context's supported CS compression algorithms.
|
ComponentFactory<SshCompression> |
supportedCompressionsSC()
Get this context's supported SC compression algorithms.
|
ComponentFactory<SshKeyExchange> |
supportedKeyExchanges()
Get this context's supported key exchange methods.
|
ComponentFactory<SshHmac> |
supportedMacsCS()
Get this context's supported message authentication algorithms CS.
|
ComponentFactory<SshHmac> |
supportedMacsSC()
Get this context's supported message authentication algorithms SC.
|
ComponentFactory<SshPublicKey> |
supportedPublicKeys()
Get this context's supported public keys.
|
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 CIPHER_CHACHA20_POLY1305
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 COMPRESSION_ZLIB_OPENSSH
public static final String KEX_DIFFIE_HELLMAN_GROUP1_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP14_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_ECDH_NISTP_256
public static final String KEX_DIFFIE_HELLMAN_ECDH_NISTP_384
public static final String KEX_DIFFIE_HELLMAN_ECDH_NISTP_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 KEX_DIFFIE_HELLMAN_GROUP14_SHA256
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 PUBLIC_KEY_SSHDSS
public static final String PUBLIC_KEY_SSHRSA
public static final String PUBLIC_KEY_X509_SIGN_RSA
public static final String PUBLIC_KEY_X509_SIGN_RSA_SHA1
public static final String PUBLIC_KEY_X509_SIGN_DSA
public static final String PUBLIC_KEY_ECDSA_256
public static final String PUBLIC_KEY_ECDSA_384
public static final String PUBLIC_KEY_ECDSA_521
public static final String PUBLIC_KEY_ED25519
public static final String PUBLIC_KEY_RSA_SHA256
public static final String PUBLIC_KEY_RSA_SHA512
public Ssh2Context()
throws SshException
SshExceptionpublic Ssh2Context(SecurityPolicy securityPolicy) throws SshException
SshExceptionpublic boolean getTemporaryValue(String name, boolean defaultValue)
public void setTemporaryValue(String name, boolean value)
public int getMaximumPacketLength()
public void setGssCallback(MaverickCallbackHandler gsscall)
public MaverickCallbackHandler getGssCallback()
public void setMaximumPacketLength(int maxPacketLength)
maxPacketLength - intpublic void setChannelLimit(int maxChannels)
SshContextsetChannelLimit in interface SshContextpublic int getChannelLimit()
SshContextgetChannelLimit in interface SshContextpublic void setX11Display(String xDisplay)
SshContextsetX11Display in interface SshContextxDisplay - the display in the form localhost:1public String getX11Display()
SshContextgetX11Display in interface SshContextpublic byte[] getX11AuthenticationCookie()
throws SshException
SshContextgetX11AuthenticationCookie in interface SshContextSshExceptionpublic void setX11AuthenticationCookie(byte[] x11FakeCookie)
SshContextsetX11AuthenticationCookie in interface SshContextpublic void setX11RealCookie(byte[] x11RealCookie)
SshContextsetX11RealCookie in interface SshContextpublic byte[] getX11RealCookie()
throws SshException
SshContextgetX11RealCookie in interface SshContextSshExceptionpublic void disableETM()
public void enableETM()
public boolean isEnableETM()
public void disableNonStandardAlgorithms()
public void enableNonStandardAlgorithms()
public boolean isNonStandardAlgorithmsEnabled()
public void setX11RequestListener(ForwardingRequestListener x11Listener)
SshContextsetX11RequestListener in interface SshContextpublic ForwardingRequestListener getX11RequestListener()
SshContextgetX11RequestListener in interface SshContextpublic BannerDisplay getBannerDisplay()
public void setBannerDisplay(BannerDisplay bannerdisplay)
bannerdisplay - the banner display, may be nullpublic ComponentFactory<SshCipher> supportedCiphersSC()
public ComponentFactory<SshCipher> supportedCiphersCS()
public String getPreferredCipherCS()
public void setPreferredCipherCS(String name) throws SshException
name - SshExceptionpublic String getPreferredCipherSC()
public String getCiphersCS()
public String getCiphersSC()
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.SshExceptionpublic void setPreferredCipherCS(int[] order)
throws SshException
order - , list of indices to be moved to the top.SshExceptionpublic void setCipherPreferredPositionCS(String name, int position) throws SshException
SshExceptionpublic void setCipherPreferredPositionSC(String name, int position) throws SshException
SshExceptionpublic void setMacPreferredPositionSC(String name, int position) throws SshException
SshExceptionpublic void setMacPreferredPositionCS(String name, int position) throws SshException
SshExceptionpublic void setPreferredMacSC(int[] order)
throws SshException
order - , list of indices to be moved to the top.SshExceptionpublic void setPreferredMacCS(int[] order)
throws SshException
order - , list of indices to be moved to the top.SshExceptionpublic void setPreferredCipherSC(String name) throws SshException
name - SshExceptionpublic ComponentFactory<SshHmac> supportedMacsSC()
public ComponentFactory<SshHmac> supportedMacsCS()
public String getPreferredMacCS()
public void setPreferredMacCS(String name) throws SshException
name - SshExceptionpublic String getPreferredMacSC()
public void setPreferredMacSC(String name) throws SshException
name - SshExceptionpublic ComponentFactory<SshCompression> supportedCompressionsSC()
public ComponentFactory<SshCompression> supportedCompressionsCS()
public String getPreferredCompressionCS()
public void setPreferredCompressionCS(String name) throws SshException
name - SshExceptionpublic String getPreferredCompressionSC()
public void setPreferredCompressionSC(String name) throws SshException
name - SshExceptionpublic void enableCompression()
throws SshException
SshExceptionpublic void disableCompression()
throws SshException
SshExceptionpublic ComponentFactory<SshKeyExchange> supportedKeyExchanges()
public String getPreferredKeyExchange()
public void setPreferredKeyExchange(String name) throws SshException
name - SshExceptionpublic ComponentFactory<SshPublicKey> supportedPublicKeys()
public String getPreferredPublicKey()
public void setPreferredPublicKey(String name) throws SshException
name - SshExceptionpublic void setHostKeyVerification(HostKeyVerification verify)
setHostKeyVerification in interface SshContextverify - public HostKeyVerification getHostKeyVerification()
getHostKeyVerification in interface SshContextpublic void setSFTPProvider(String sftpProvider)
SshContextsetSFTPProvider in interface SshContextpublic String getSFTPProvider()
SshContextgetSFTPProvider in interface SshContextpublic void setPartialMessageTimeout(int partialMessageTimeout)
partialMessageTimeout - public int getPartialMessageTimeout()
public boolean isKeyReExchangeDisabled()
public void setKeyReExchangeDisabled(boolean keyReExchangeDisabled)
public void setPublicKeyPreferredPosition(String name, int position) throws SshException
SshExceptionpublic void setKeyExchangePreferredPosition(String name, int position) throws SshException
SshExceptionpublic int getIdleConnectionTimeoutSeconds()
public void setIdleConnectionTimeoutSeconds(int idleConnectionTimeoutSeconds)
public void setTreatIdleConnectionAsError(boolean treatIdleConnectionAsError)
public boolean isTreatIdleConnectionAsError()
public boolean isDHGroupExchangeBackwardsCompatible()
public int getDHGroupExchangeKeySize()
public void setDHGroupExchangeKeySize(int dhGroupExchangeKeySize)
public void setDHGroupExchangeBackwardsCompatible(boolean dhGroupExchangeBackwardCompatible)
public boolean isSendIgnorePacketOnIdle()
public void setSendIgnorePacketOnIdle(boolean sendIgnorePacketOnIdle)
public int getKeepAliveMaxDataLength()
public void setKeepAliveMaxDataLength(int keepAliveMaxDataLength)
public int getSocketTimeout()
public void setSocketTimeout(int socketTimeout)
public void setMessageTimeout(int messageTimeout)
setMessageTimeout in interface SshContextpublic int getMessageTimeout()
getMessageTimeout in interface SshContext@Deprecated public void enableFIPSMode() throws SshException
SshContextenableFIPSMode in interface SshContextSshExceptionpublic int getSftpMaxWindowSpace()
public int getSftpMaxPacketSize()
public void setSftpMaxWindowSpace(int sftpMaxWindowSpace)
public void setSftpMaxPacketSize(int sftpMaxPacketSize)
public int getSessionMaxWindowSpace()
public int getSessionMaxPacketSize()
public void setSessionMaxWindowSpace(int sessionMaxWindowSpace)
public void setSessionMaxPacketSize(int sessionMaxPacketSize)
public int getMaxNumPacketsBeforeReKey()
public int getMaxNumBytesBeforeReKey()
public void setMaxNumBytesBeforeReKey(int maxNumBytesBeforeReKey)
public void setMaxNumPacketsBeforeReKey(int maxNumPacketsBeforeReKey)
public ExecutorService getExecutorService()
getExecutorService in interface ExecutorServiceProviderpublic void setExecutorService(ExecutorService executor)
setExecutorService in interface ExecutorServiceProviderpublic void setPreferKeyboardInteractiveOverPassword(boolean preferKeyboardInteractiveOverPassword)
public boolean isPreferKeyboardInteractiveOverPassword()
public void setMinDHGroupSize(int minDHGroupSize)
public int getMinDHGroupSize()
public void setMaxDHGroupSize(int maxDHGroupSize)
public int getMaxDHGroupSize()
public boolean allowHostKeyUpdates()
public void setAllowHostKeyUpdates(boolean value)
public SecurityPolicy getSecurityPolicy()
public boolean isLimitPublicKeysToKnownHosts()
public void setLimitPublicKeysToKnownHosts(boolean limitPublicKeysToKnownHosts)
@Deprecated public boolean isTriedBackwardsCompatibility()
@Deprecated public void setTriedBackwardsCompatibility(boolean triedBackwardsCompatibility)
@Deprecated public boolean isTriedMinimalKeyExchangePacket()
@Deprecated public void setTriedMinimalKeyExchangePacket(boolean triedMinimalKeyExchangePacket)
public boolean isSHA1SignaturesSupported()
SshContextisSHA1SignaturesSupported in interface SshContextpublic void setSHA1SignaturesSupported(boolean supportSHA1Signatures)
SshContextsetSHA1SignaturesSupported in interface SshContextpublic int getIdleAuthenticationTimeoutSeconds()
public void setIdleAuthenticationTimeoutSeconds(int idleAuthenticationTimeoutSeconds)
public void configureSecurityLevel(SecurityLevel securityLevel) throws SshException
SshExceptionCopyright © 2025. All rights reserved.