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, startNewSession
public void runWithPortFwd() throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public void runWithCommand(java.lang.String command) throws java.io.IOException
command
- Command to executejava.io.IOException
public void runWithCommandInShell(java.lang.String command) throws java.io.IOException
command
- Command to executejava.io.IOException
public void runSCP(java.lang.String remotefile) throws java.io.IOException
remotefile
- File on remote system to transferjava.io.IOException
public java.lang.String getUsername(SSHClientUser origin) throws java.io.IOException
getUsername
in interface SSHAuthenticator
java.io.IOException
public java.lang.String getPassword(SSHClientUser origin) throws java.io.IOException
getPassword
in interface SSHAuthenticator
java.io.IOException
public java.lang.String getChallengeResponse(SSHClientUser origin, java.lang.String challenge) throws java.io.IOException
getChallengeResponse
in interface SSHAuthenticator
java.io.IOException
public int[] getAuthTypes(SSHClientUser origin)
getAuthTypes
in interface SSHAuthenticator
public int getCipher(SSHClientUser origin)
getCipher
in interface SSHAuthenticator
public SSHRSAKeyFile getIdentityFile(SSHClientUser origin) throws java.io.IOException
getIdentityFile
in interface SSHAuthenticator
java.io.IOException
public java.lang.String getIdentityPassword(SSHClientUser origin) throws java.io.IOException
getIdentityPassword
in interface SSHAuthenticator
java.io.IOException
public boolean verifyKnownHosts(java.security.interfaces.RSAPublicKey hostPub) throws java.io.IOException
verifyKnownHosts
in interface SSHAuthenticator
hostPub
- public key of remote hostjava.io.IOException
public java.lang.String getSrvHost() throws java.io.IOException
getSrvHost
in interface SSHClientUser
java.io.IOException
public int getSrvPort()
getSrvPort
in interface SSHClientUser
public NetworkConnection getProxyConnection() throws java.io.IOException
getProxyConnection
in interface SSHClientUser
java.io.IOException
public java.lang.String getDisplay()
getDisplay
in interface SSHClientUser
public int getMaxPacketSz()
getMaxPacketSz
in interface SSHClientUser
public int getAliveInterval()
getAliveInterval
in interface SSHClientUser
public int getCompressionLevel()
getCompressionLevel
in interface SSHClientUser
public boolean wantX11Forward()
wantX11Forward
in interface SSHClientUser
public boolean wantPTY()
wantPTY
in interface SSHClientUser
public int getKexTimeout()
getKexTimeout
in interface SSHClientUser
public int getConnectTimeout()
getConnectTimeout
in interface SSHClientUser
public int getHelloTimeout()
getHelloTimeout
in interface SSHClientUser
public SSHInteractor getInteractor()
getInteractor
in interface SSHClientUser
public static void main(java.lang.String[] argv)