examples
Class SSH1Cisco

java.lang.Object
  extended by com.mindbright.ssh.SSHInteractorAdapter
      extended by examples.SSH1Cisco
All Implemented Interfaces:
SSHAuthenticator, SSHClientUser, SSHInteractor

public class SSH1Cisco
extends SSHInteractorAdapter
implements SSHAuthenticator, SSHClientUser

Examples on how to connect to an old Cisco device and send a single command. All using the ssh1 classes.

Usage: java -cp examples.jar examples.SSH1Cisco host port username password command


Method Summary
 void close()
          Close connection
 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 desirect encryption algorithm
 int getCompressionLevel()
          Get desired level of compression
 java.lang.String getDisplay()
          Get the display for X11 forwardings
 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 getMaxPacketSz()
          get maximum packet size (0 = no limit)
 java.lang.String getPassword(SSHClientUser origin)
          Get password to log in with
 java.net.Socket 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 runCmd(java.lang.String command)
          Start a shell over SSH1 connection and run a command and retrieve the output
 boolean verifyKnownHosts(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
 
Methods inherited from class com.mindbright.ssh.SSHInteractorAdapter
alert, askConfirmation, connected, disconnected, isVerbose, licenseDialog, open, promptLine, promptPassword, propsStateChanged, quietPrompts, report, sessionStarted, startNewSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

runCmd

public void runCmd(java.lang.String command)
            throws java.io.IOException
Start a shell over SSH1 connection and run a command and retrieve the output

Parameters:
command - Command to execute
Throws:
java.io.IOException

close

public void close()
Close connection


getUsername

public java.lang.String getUsername(SSHClientUser origin)
                             throws java.io.IOException
Get username to log in as

Specified by:
getUsername in interface SSHAuthenticator
Throws:
java.io.IOException

getPassword

public java.lang.String getPassword(SSHClientUser origin)
                             throws java.io.IOException
Get password to log in with

Specified by:
getPassword in interface SSHAuthenticator
Throws:
java.io.IOException

getChallengeResponse

public java.lang.String getChallengeResponse(SSHClientUser origin,
                                             java.lang.String challenge)
                                      throws java.io.IOException
Present challenge to user an return answer

Specified by:
getChallengeResponse in interface SSHAuthenticator
Throws:
java.io.IOException

getAuthTypes

public int[] getAuthTypes(SSHClientUser origin)
Get the authentication method the user wants to us

Specified by:
getAuthTypes in interface SSHAuthenticator

getCipher

public int getCipher(SSHClientUser origin)
Get desirect encryption algorithm

Specified by:
getCipher in interface SSHAuthenticator

getIdentityFile

public SSHRSAKeyFile getIdentityFile(SSHClientUser origin)
                              throws java.io.IOException
Return name of file containing private key for pubkey authentication

Specified by:
getIdentityFile in interface SSHAuthenticator
Throws:
java.io.IOException

getIdentityPassword

public java.lang.String getIdentityPassword(SSHClientUser origin)
                                     throws java.io.IOException
Return password protecting identify file

Specified by:
getIdentityPassword in interface SSHAuthenticator
Throws:
java.io.IOException

verifyKnownHosts

public boolean verifyKnownHosts(RSAPublicKey hostPub)
                         throws java.io.IOException
Verify the fingerprint of the remote host.

Specified by:
verifyKnownHosts in interface SSHAuthenticator
Parameters:
hostPub - public key of remote host
Returns:
true if the public key verifies
Throws:
java.io.IOException

getSrvHost

public java.lang.String getSrvHost()
                            throws java.io.IOException
Get host to connect to

Specified by:
getSrvHost in interface SSHClientUser
Throws:
java.io.IOException

getSrvPort

public int getSrvPort()
Get port number to connect to

Specified by:
getSrvPort in interface SSHClientUser

getProxyConnection

public java.net.Socket getProxyConnection()
                                   throws java.io.IOException
Return a connection to the server. This can be used to connect through proxies etc.

Specified by:
getProxyConnection in interface SSHClientUser
Throws:
java.io.IOException

getDisplay

public java.lang.String getDisplay()
Get the display for X11 forwardings

Specified by:
getDisplay in interface SSHClientUser

getMaxPacketSz

public int getMaxPacketSz()
get maximum packet size (0 = no limit)

Specified by:
getMaxPacketSz in interface SSHClientUser

getAliveInterval

public int getAliveInterval()
Get alive interval (0 = do not send keepalive packets)

Specified by:
getAliveInterval in interface SSHClientUser

getCompressionLevel

public int getCompressionLevel()
Get desired level of compression

Specified by:
getCompressionLevel in interface SSHClientUser

wantX11Forward

public boolean wantX11Forward()
Return true if X11 forwarding is desired

Specified by:
wantX11Forward in interface SSHClientUser

wantPTY

public boolean wantPTY()
Return true if we need a PTY on the server

Specified by:
wantPTY in interface SSHClientUser

getInteractor

public SSHInteractor getInteractor()
Get interactor which should handle the authentication phase

Specified by:
getInteractor in interface SSHClientUser

main

public static void main(java.lang.String[] argv)
Run the application