allows Qore programs to establish an ssh2 connection to a remote server
More...
|
| constructor (string url, softint port=0) |
| creates the object with the given hostname and port number
|
|
| copy () |
| throws an exception; currently SSH2Client objects cannot be copied
|
|
hash | info () |
| returns a hash with information about the current connection status
|
|
SSH2Channel | openDirectTcpipChannel (string host, softint port, string source_host="127.0.0.1", softint source_port=22, timeout timeout=-1) |
| Opens a port forwarding channel and returns the corresponding SSH2Channel object for the new forwarded connection.
|
|
SSH2Channel | openSessionChannel (timeout timeout=-1) |
| Opens a login session and returns a SSH2Channel object for the session.
|
|
SSH2Channel | scpGet (string path, timeout timeout=-1, *reference statinfo) |
| opens a channel for retrieving a remote file with an optional timeout value and an optional reference for returning file status information
|
|
SSH2Channel | scpPut (string remote_path, softint size, softint mode=0644, *date mtime, *date atime, timeout timeout=-1) |
| Opens a channel for sending a file to the remote server; an SSH2Channel object is returned to use to send the file's data.
|
|
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.
|
|
allows Qore programs to establish an ssh2 connection to a remote server
Qore::SSH2::SSH2Client::constructor |
( |
string |
url, |
|
|
softint |
port = 0 |
|
) |
| |
creates the object with the given hostname and port number
- Parameters
-
url | the remote host to connect to - can also be a url like "ssh://user:pass@hostname:port" |
port | the port number on the remote host to connect to; if the port is 0, then the port given in the url argument is used; if none is given there, then the default port is used (22) |
- Exceptions
-
SSH2CLIENT-PARAMETER-ERROR | empty url passed |
- Example:
my $ssh2client SSH2Client("host", 4022);
Qore::SSH2::SSH2Client::copy |
( |
| ) |
|
throws an exception; currently SSH2Client objects cannot be copied
- Exceptions
-
SSH2CLIENT-COPY-ERROR | copying SSH2Client objects is not currently implemented |
hash Qore::SSH2::SSH2Client::info |
( |
| ) |
|
returns a hash with information about the current connection status
this method is safe to call when not connected
- Returns
- a hash with the following keys:
ssh2host:
(string) the host name of the remote server
ssh2port:
(int) the port number of the remote server
ssh2user:
(string) the user name used for the connection
keyfile_priv:
(string) the filename of the local private key file used
keyfile_pub:
(string) the filename of the local public key file used
fingerprint:
(*string) The fingerprint of the public host key of the remote server as a string of hex digit pairs separated by colons (:), ex: "AC:AA:DF:3F:49:82:5A:1A:DE:C9:ED:14:00:7D:65:9E"
or NOTHING
if not connected
authenticated:
(*string) a string giving the authentication mechanism used: "publickey"
, "password"
, "keyboard-interactive"
or NOTHING
if not connected
connected:
(bool) tells if the connection is currently active or not
methods:
(hash) a hash of strings giving the crytographic methods used for the connection
- Code Flags:
- CONSTANT
- Example:
my hash $h = $ssh2client.info();
SSH2Channel Qore::SSH2::SSH2Client::openDirectTcpipChannel |
( |
string |
host, |
|
|
softint |
port, |
|
|
string |
source_host = "127.0.0.1" , |
|
|
softint |
source_port = 22 , |
|
|
timeout |
timeout = -1 |
|
) |
| |
Opens a port forwarding channel and returns the corresponding SSH2Channel object for the new forwarded connection.
- Parameters
-
host | the remote host to connect to |
port | the port number on the remote host to connect to |
source_host | the host name to report as the source of the connection |
source_port | the port number to report as the source of the connection |
timeout | an integer giving a timeout in milliseconds or a relative date/time value (ex: 15s for 15 seconds) |
- Exceptions
-
SSH2CLIENT-OPENDIRECTTCPIPCHANNEL-ERROR | port number for forwarded channel as second argument cannot be zero; source port number as fourth argument cannot be zero |
SSH2CLIENT-NOT-CONNECTED | client is not connected |
SSH2CLIENT-TIMEOUT | timeout opening channel |
SSH2-ERROR | error opening channel |
- Example:
my SS2Channel $chan = $ssh2client.("host", 4022, NOTHING, NOTHING, 30s);
SSH2Channel Qore::SSH2::SSH2Client::openSessionChannel |
( |
timeout |
timeout = -1 | ) |
|
Opens a login session and returns a SSH2Channel object for the session.
- Parameters
-
timeout | an integer giving a timeout in milliseconds or a relative date/time value (ex: 15s for 15 seconds) |
- Exceptions
-
SSH2CLIENT-NOT-CONNECTED | client is not connected |
SSH2CLIENT-TIMEOUT | timeout opening channel |
SSH2-ERROR | error opening channel |
- Example:
my SSH2Channel $chan = $ssh2client.openSessionChannel(30s);
SSH2Channel Qore::SSH2::SSH2Client::scpGet |
( |
string |
path, |
|
|
timeout |
timeout = -1 , |
|
|
*reference |
statinfo |
|
) |
| |
opens a channel for retrieving a remote file with an optional timeout value and an optional reference for returning file status information
an SSH2Channel object is returned to use to retrieve the file's data
- Parameters
-
path | the path of the remote file to get |
timeout | an integer giving a timeout in milliseconds or a relative date/time value (ex: 15s for 15 seconds) |
statinfo | an optional reference to a hash for file status info with the following keys:
"mode" : the file's mode
"permissions" : a string of the file's mode (ex: "drwxr-xr-x" )
"size" : the size of the file in bytes
"atime" : the last access time of the file
"mtime" : the last modified time of the file
|
- Exceptions
-
SSH2CLIENT-NOT-CONNECTED | client is not connected |
SSH2CLIENT-TIMEOUT | timeout opening channel |
SSH2-ERROR | error opening channel |
- Example:
my hash $info;
my SS2Channel $chan = $ssh2client.scpGet("/tmp/file.txt", 30s, \$info);
SSH2Channel Qore::SSH2::SSH2Client::scpPut |
( |
string |
remote_path, |
|
|
softint |
size, |
|
|
softint |
mode = 0644 , |
|
|
*date |
mtime, |
|
|
*date |
atime, |
|
|
timeout |
timeout = -1 |
|
) |
| |
Opens a channel for sending a file to the remote server; an SSH2Channel object is returned to use to send the file's data.
- Parameters
-
remote_path | the path of the file to save on the remote server |
size | the size of the file to send; this parameter is required |
mode | the file's mode on the remote machine |
mtime | the file's last modified time to create on the remote machine |
atime | the file's last access time to create on the remote machine |
timeout | an integer giving a timeout in milliseconds or a relative date/time value (ex: 15s for 15 seconds) |
- Exceptions
-
SSH2CLIENT-NOT-CONNECTED | client is not connected |
SSH2CLIENT-TIMEOUT | timeout opening channel |
SSH2-ERROR | error opening channel |
- Example:
my SS2Channel $chan = $ssh2client.scpPut("/tmp/file.txt", $size, 0644, 2010-12-25, 2010-12-25, 30s);
The documentation for this class was generated from the following file:
- /home/david/src/qore/svn/module-ssh2/trunk/src/QC_SSH2Client.dox.h