examples
public class SSH1Example extends SSHInteractorAdapter implements SSHAuthenticator, SSHClientUser
NOTE that the ssh1 protocol is a deprecated protocol with known security vulnerabilities. Use version 2 if at all possible. Moreover the SSH1 api in MindTerm is less structured and harder to use. That said this class contains code demonstrating:
java -cp examples.jar examples.SSH1Example
host port username password| Modifier and Type | Method and Description |
|---|---|
int |
getAliveInterval()
Get alive interval (0 = do not send keepalive packets)
|
int[] |
getAuthTypes(SSHClientUser origin)
Get the authentication method the user wants to us
|
java.lang.String |
getChallengeResponse(SSHClientUser origin,
java.lang.String challenge)
Present challenge to user an return answer
|
int |
getCipher(SSHClientUser origin)
Get desired encryption algorithm
|
int |
getCompressionLevel()
Get desired level of compression
|
int |
getConnectTimeout()
Timeout when connecting to server (in seconds)
|
java.lang.String |
getDisplay()
Get the display for X11 forwardings
|
int |
getHelloTimeout()
Timeout when waiting for initial greeting from server (in seconds)
|
SSHRSAKeyFile |
getIdentityFile(SSHClientUser origin)
Return name of file containing private key for pubkey authentication
|
java.lang.String |
getIdentityPassword(SSHClientUser origin)
Return password protecting identify file
|
SSHInteractor |
getInteractor()
Get interactor which should handle the authentication phase
|
int |
getKexTimeout()
Timeout of key exchange (in seconds)
|
int |
getMaxPacketSz()
get maximum packet size (0 = no limit)
|
java.lang.String |
getPassword(SSHClientUser origin)
Get password to log in with
|
NetworkConnection |
getProxyConnection()
Return a connection to the server.
|
java.lang.String |
getSrvHost()
Get host to connect to
|
int |
getSrvPort()
Get port number to connect to
|
java.lang.String |
getUsername(SSHClientUser origin)
Get username to log in as
|
static void |
main(java.lang.String[] argv)
Run the application
|
void |
runSCP(java.lang.String remotefile)
Transfer files with SCP
|
void |
runWithCommand(java.lang.String command)
Start a command over SSH1 connection and run a command and
retrieve the output
|
void |
runWithCommandInShell(java.lang.String command)
Start a shell over SSH1 connection and run a command and
retrieve the output
|
void |
runWithPortFwd()
Start an SSH1 connection with port forward.
|
boolean |
verifyKnownHosts(java.security.interfaces.RSAPublicKey hostPub)
Verify the fingerprint of the remote host.
|
boolean |
wantPTY()
Return true if we need a PTY on the server
|
boolean |
wantX11Forward()
Return true if X11 forwarding is desired
|
alert, askConfirmation, connected, disconnected, isVerbose, licenseDialog, open, promptLine, promptPassword, propsStateChanged, quietPrompts, report, sessionStarted, startNewSessionpublic void runWithPortFwd()
throws java.net.UnknownHostException,
java.io.IOException
java.net.UnknownHostExceptionjava.io.IOExceptionpublic void runWithCommand(java.lang.String command)
throws java.io.IOException
command - Command to executejava.io.IOExceptionpublic void runWithCommandInShell(java.lang.String command)
throws java.io.IOException
command - Command to executejava.io.IOExceptionpublic void runSCP(java.lang.String remotefile)
throws java.io.IOException
remotefile - File on remote system to transferjava.io.IOExceptionpublic java.lang.String getUsername(SSHClientUser origin) throws java.io.IOException
getUsername in interface SSHAuthenticatorjava.io.IOExceptionpublic java.lang.String getPassword(SSHClientUser origin) throws java.io.IOException
getPassword in interface SSHAuthenticatorjava.io.IOExceptionpublic java.lang.String getChallengeResponse(SSHClientUser origin, java.lang.String challenge) throws java.io.IOException
getChallengeResponse in interface SSHAuthenticatorjava.io.IOExceptionpublic int[] getAuthTypes(SSHClientUser origin)
getAuthTypes in interface SSHAuthenticatorpublic int getCipher(SSHClientUser origin)
getCipher in interface SSHAuthenticatorpublic SSHRSAKeyFile getIdentityFile(SSHClientUser origin) throws java.io.IOException
getIdentityFile in interface SSHAuthenticatorjava.io.IOExceptionpublic java.lang.String getIdentityPassword(SSHClientUser origin) throws java.io.IOException
getIdentityPassword in interface SSHAuthenticatorjava.io.IOExceptionpublic boolean verifyKnownHosts(java.security.interfaces.RSAPublicKey hostPub)
throws java.io.IOException
verifyKnownHosts in interface SSHAuthenticatorhostPub - public key of remote hostjava.io.IOExceptionpublic java.lang.String getSrvHost()
throws java.io.IOException
getSrvHost in interface SSHClientUserjava.io.IOExceptionpublic int getSrvPort()
getSrvPort in interface SSHClientUserpublic NetworkConnection getProxyConnection() throws java.io.IOException
getProxyConnection in interface SSHClientUserjava.io.IOExceptionpublic java.lang.String getDisplay()
getDisplay in interface SSHClientUserpublic int getMaxPacketSz()
getMaxPacketSz in interface SSHClientUserpublic int getAliveInterval()
getAliveInterval in interface SSHClientUserpublic int getCompressionLevel()
getCompressionLevel in interface SSHClientUserpublic boolean wantX11Forward()
wantX11Forward in interface SSHClientUserpublic boolean wantPTY()
wantPTY in interface SSHClientUserpublic int getKexTimeout()
getKexTimeout in interface SSHClientUserpublic int getConnectTimeout()
getConnectTimeout in interface SSHClientUserpublic int getHelloTimeout()
getHelloTimeout in interface SSHClientUserpublic SSHInteractor getInteractor()
getInteractor in interface SSHClientUserpublic static void main(java.lang.String[] argv)