com.mindbright.ssh2
Class SSH2SimpleClient

java.lang.Object
  extended by com.mindbright.ssh2.SSH2SimpleClient

public class SSH2SimpleClient
extends java.lang.Object

This class implements the most basic variant of a ssh2 client. It creates the userauth, and connection layers (i.e. instances of SSH2UserAuth, and SSH2Connection). The only thing which needs to be provided is an initialized SSH2Transport instance, user authentication data. The constructor is active in that it does all the required work to set up the complete protocol stack, hence it can throw exceptions which can occur.

This simple client can easily be used as the basis for example to build tunneling capabilities into any java app. requiring secure connections. For doing remote command execution and/or controlling input/output of a command or shell the class SSH2ConsoleRemote can be used to have easy access to command execution and/or input/output as java.io.InputStream and java.io.OutpuStream

See Also:
SSH2Transport, SSH2Connection, SSH2ConsoleRemote, SSH2Preferences, RunRemoteCommand, RemoteShellScript

Field Summary
protected  SSH2Connection connection
           
protected  SSH2Transport transport
           
protected  SSH2UserAuth userAuth
           
 
Constructor Summary
SSH2SimpleClient(SSH2Transport transport, boolean hostbased, java.lang.String username, java.lang.String keyFile, java.lang.String keyPassword)
          Simple constructor to use for publickey / hostbased authentication.
SSH2SimpleClient(SSH2Transport transport, boolean hostbased, java.lang.String username, java.lang.String keyFile, java.lang.String keyPassword, long timeout)
          Simple constructor to use for publickey / hostbased authentication.
SSH2SimpleClient(SSH2Transport transport, SSH2Authenticator authenticator)
          Constructor to use when more than one authentication method need to be used and/or other methods than the ones supported above.
SSH2SimpleClient(SSH2Transport transport, SSH2Authenticator authenticator, long timeout)
          Constructor to use when more than one authentication method need to be used and/or other methods than the ones supported above.
SSH2SimpleClient(SSH2Transport transport, java.lang.String username, long timeout)
          Constructor to use for GSSAPI authentication.
SSH2SimpleClient(SSH2Transport transport, java.lang.String username, SSH2Interactor interactor)
          Constructor to use for keyboard interactive authentication.
SSH2SimpleClient(SSH2Transport transport, java.lang.String username, SSH2Interactor interactor, long timeout)
          Constructor to use for keyboard interactive authentication.
SSH2SimpleClient(SSH2Transport transport, java.lang.String username, java.lang.String password)
          Simple constructor to use for password authentication.
SSH2SimpleClient(SSH2Transport transport, java.lang.String username, java.lang.String password, long timeout)
          Simple constructor to use for password authentication.
SSH2SimpleClient(SSH2Transport transport, java.lang.String username, java.lang.String keyFile, java.lang.String keyPassword)
          Simple constructor to use for publickey authentication.
SSH2SimpleClient(SSH2Transport transport, java.lang.String username, java.lang.String keyFile, java.lang.String keyPassword, long timeout)
          Simple constructor to use for publickey authentication.
 
Method Summary
 SSH2Connection getConnection()
           
 SSH2Transport getTransport()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transport

protected SSH2Transport transport

connection

protected SSH2Connection connection

userAuth

protected SSH2UserAuth userAuth
Constructor Detail

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        java.lang.String username,
                        java.lang.String password,
                        long timeout)
                 throws SSH2Exception
Simple constructor to use for password authentication. This will actually be able to use both the password and keyboard interactive authentication protocols.

Parameters:
transport - connected transport layer
username - name of user
password - password of user
timeout - timeout in milliseconds for authentication phase (0 means no timeout)
Throws:
SSH2Exception
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        java.lang.String username,
                        java.lang.String password)
                 throws SSH2Exception
Simple constructor to use for password authentication. This will actually be able to use both the password and keyboard interactive authentication protocols.

Parameters:
transport - connected transport layer
username - name of user
password - password of user
Throws:
SSH2Exception
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        java.lang.String username,
                        java.lang.String keyFile,
                        java.lang.String keyPassword)
                 throws SSH2Exception,
                        java.io.IOException
Simple constructor to use for publickey authentication.

Parameters:
transport - connected transport layer
username - name of user
keyFile - name of private key file to use for authentication
keyPassword - password protecting private key file (null if none)
Throws:
SSH2Exception
java.io.IOException
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        java.lang.String username,
                        java.lang.String keyFile,
                        java.lang.String keyPassword,
                        long timeout)
                 throws SSH2Exception,
                        java.io.IOException
Simple constructor to use for publickey authentication.

Parameters:
transport - connected transport layer
username - name of user
keyFile - name of private key file to use for authentication
keyPassword - password protecting private key file (null if none)
timeout - timeout in milliseconds for authentication phase (0 means no timeout)
Throws:
SSH2Exception
java.io.IOException
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        boolean hostbased,
                        java.lang.String username,
                        java.lang.String keyFile,
                        java.lang.String keyPassword)
                 throws SSH2Exception,
                        java.io.IOException
Simple constructor to use for publickey / hostbased authentication.

Parameters:
transport - connected transport layer
hostbased - whether hostbased or publickey auth. should be used, set to true to use hostbased, and false to use publickey
username - name of user
keyFile - name of private key file to use for authentication
keyPassword - password protecting private key file (null if none)
Throws:
SSH2Exception
java.io.IOException
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        boolean hostbased,
                        java.lang.String username,
                        java.lang.String keyFile,
                        java.lang.String keyPassword,
                        long timeout)
                 throws SSH2Exception,
                        java.io.IOException
Simple constructor to use for publickey / hostbased authentication.

Parameters:
transport - connected transport layer
hostbased - whether hostbased or publickey auth. should be used, set to true to use hostbased, and false to use publickey
username - name of user
keyFile - name of private key file to use for authentication
keyPassword - password protecting private key file (null if none)
timeout - timeout in milliseconds for authentication phase (0 means no timeout)
Throws:
SSH2Exception
java.io.IOException
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        java.lang.String username,
                        SSH2Interactor interactor,
                        long timeout)
                 throws SSH2Exception
Constructor to use for keyboard interactive authentication.

Parameters:
transport - connected transport layer
username - name of user
interactor - interactor instance to handle user interaction in authentication
timeout - timeout in milliseconds for authentication phase (0 means no timeout)
Throws:
SSH2Exception
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        java.lang.String username,
                        SSH2Interactor interactor)
                 throws SSH2Exception
Constructor to use for keyboard interactive authentication.

Parameters:
transport - connected transport layer
username - name of user
interactor - interactor instance to handle user interaction in authentication
Throws:
SSH2Exception
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        java.lang.String username,
                        long timeout)
                 throws SSH2Exception
Constructor to use for GSSAPI authentication.

Parameters:
transport - connected transport layer
username - name of user
timeout - timeout in milliseconds for authentication phase (0 means no timeout)
Throws:
SSH2Exception
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        SSH2Authenticator authenticator)
                 throws SSH2Exception
Constructor to use when more than one authentication method need to be used and/or other methods than the ones supported above.

Parameters:
transport - connected transport layer
authenticator - authenticator instance prepared with needed methods
Throws:
SSH2Exception
See Also:
SSH2Transport

SSH2SimpleClient

public SSH2SimpleClient(SSH2Transport transport,
                        SSH2Authenticator authenticator,
                        long timeout)
                 throws SSH2Exception
Constructor to use when more than one authentication method need to be used and/or other methods than the ones supported above.

Parameters:
transport - connected transport layer
authenticator - authenticator instance prepared with needed methods
timeout - timeout in milliseconds for authentication phase (0 means no timeout)
Throws:
SSH2Exception
See Also:
SSH2Transport
Method Detail

getTransport

public SSH2Transport getTransport()

getConnection

public SSH2Connection getConnection()