Qore SSH2 Module  0.9.7
 All Classes Namespaces Functions
Qore::SSH2::SSH2Base Class Reference

base class for SFTPClient and SSH2Client More...

Inheritance diagram for Qore::SSH2::SSH2Base:

Public Member Functions

nothing connect (timeout timeout=-1)
 connect to remote system
 
 constructor ()
 Throws an exception; the constructor cannot be called manually.
 
nothing disconnect ()
 Disconnects from the remote system; throws an exception if the object is not currently connected.
 
nothing setKeys (string priv_key, *string pub_key)
 Sets path to the private key and optionally the public key to use for the next connection; can only be called when a connection is not established, otherwise an exception is thrown.
 
nothing setPassword (string pass)
 Sets the password for the next connection; can only be called when a connection is not established, otherwise an exception is thrown.
 
nothing setUser (string user)
 Sets the user name for the next connection; can only be called when a connection is not established, otherwise an exception is thrown.
 

Detailed Description

base class for SFTPClient and SSH2Client

The SSH2Base class provides common methods to the SSH2Client and SFTPClient classes

Member Function Documentation

nothing Qore::SSH2::SSH2Base::connect ( timeout  timeout = -1)

connect to remote system

Connects to the remote system; if a connection is already established, then it is disconnected first

Parameters
timeoutan integer giving a timeout in milliseconds or a relative date/time value (ex: 15s for 15 seconds)
Exceptions
SOCKET-CONNECT-ERRORerror establishing socket connection (no listener, port blocked, etc); timeout establishing socket connection
SSH2CLIENT-CONNECT-ERRORno user name set; ssh2 or libssh2 error
SSH2-ERRORerror initializing or establishing ssh2 session
SSH2CLIENT-AUTH-ERRORno proper authentication method found
SFTPCLIENT-CONNECT-ERRORerror initializing sftp session or getting remote path (exception only possible when called from an SFTPClient object)
Example:
$sftpclient.connect(30s);
Qore::SSH2::SSH2Base::constructor ( )

Throws an exception; the constructor cannot be called manually.

Throws an exception if called directly; this class cannot be instantiated directly

Exceptions
SSH2BASE-CONSTRUCTOR-ERRORthis class is an abstract class and cannot be instantiated directly or directly inherited by a user-defined class
nothing Qore::SSH2::SSH2Base::disconnect ( )

Disconnects from the remote system; throws an exception if the object is not currently connected.

Exceptions
SSH2CLIENT-NOT-CONNECTEDthe client is not connected
Example:
$sftpclient.disconnect();
nothing Qore::SSH2::SSH2Base::setKeys ( string  priv_key,
*string  pub_key 
)

Sets path to the private key and optionally the public key to use for the next connection; can only be called when a connection is not established, otherwise an exception is thrown.

Restrictions:
Qore::PO_NO_FILESYSTEM
Parameters
priv_keythe path to the private key file to use for the next connection
pub_keyoptional: the path to the public key file to use for the next connection; note that if this argument is not passed, then the public key file's name will be automaticaly generated by appending ".pub" to the private key file's name
Exceptions
SSH2-CONNECTEDthis method cannot be called when a connection is established
SSH2-SETKEYS-ERRORthe given keys are not available or readable
Note
  • both keys must be present (private and public) and readable in order for key-based authentication to work
  • if the keys are not valid no exception is thrown here, however key-based authentication will fail with am error like: "SSH2CLIENT-AUTH-ERROR: No proper authentication method found" (the same or similar error can be raised when the server does not accept otherwise valid keys)
Example:
$sftpclient.setKeys($ENV.HOME + "/.ssh/id_rsa", $ENV.HOME + "/.ssh/id_rsa.pub");
nothing Qore::SSH2::SSH2Base::setPassword ( string  pass)

Sets the password for the next connection; can only be called when a connection is not established, otherwise an exception is thrown.

Parameters
passthe password to use for the next connection
Exceptions
SSH2-CONNECTEDthis method cannot be called when a connection is established
Example:
$sftpclient.setPassword("pass");
nothing Qore::SSH2::SSH2Base::setUser ( string  user)

Sets the user name for the next connection; can only be called when a connection is not established, otherwise an exception is thrown.

Parameters
userthe user name to set for the next connection
Exceptions
SSH2-CONNECTEDthis method cannot be called when a connection is established
Example:
$sftpclient.setUser("username");

The documentation for this class was generated from the following file: