## helma.Ssh

    Object
       |
       +--helma.Ssh

This class provides methods for connecting to a remote server via secure shell (ssh) and copying files from/to a remote server using secure copy (scp). It utilizes "Ganymed SSH-2 for Java" (see http://www.ganymed.ethz.ch/ssh2/).
Defined in Ssh.js
Author: Robert Gaggl

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Constructor Summary
`helma.Ssh(<String> server, <helma.File|java.io.File|String> hosts)` Creates a new instance of helma.Ssh

Methods Summary
`Boolean` | `addKnownHosts(<helma.File|java.io.File|String> file)` Opens the file passed as argument and adds the known hosts therein to the list of known hosts for this client.
`Boolean` | `connect(<String> username, <String> password)` Connects to a remote host using plain username/password authentication.
`Boolean` | `connectWithKey(<String> username, <helma.File|java.io.File|String> key, <String> passphrase)` Connects to a remote host using a private key and the corresponding passphrase.
`void` | `disconnect()` Disconnects this client from the remote server.
`String` | `execCommand(<String> cmd)` Executes a single command on the remote server.
`Boolean` | `get(<String|Array> remoteFile, <String> targetDir)` Retrieves a file from the remote server and stores it locally.
`Boolean` | `isConnected()` Returns true if this client is currently connected.
`Object` | `isParanoid()` Returns true if this client is in paranoid mode.
`Boolean` | `put(<String|Array> localFile, <String> remoteDir, <String> mode)` Copies a local file to the remote server
`void` | `setParanoid(<Boolean> p)` Toggles paranoid mode.

Constructor Detail

### helma.Ssh

    helma.Ssh(<String> server, <helma.File|java.io.File|String> hosts)

Creates a new instance of helma.Ssh

Parameters:

`server` - The server to connect to

`hosts` - Either a file containing a list of known hosts, or the path pointing to a file. This argument is optional.

Returns:

A newly created instance of helma.Ssh

Author: Robert Gaggl

Method Detail

### addKnownHosts

    Boolean addKnownHosts(<helma.File|java.io.File|String> file)

Opens the file passed as argument and adds the known hosts therein to the list of known hosts for this client.

Parameters:

`file` - Either a file object or the path to a file containing a list of known hosts

Returns:

True if adding the list was successful, false otherwise

### connect

    Boolean connect(<String> username, <String> password)

Connects to a remote host using plain username/password authentication.

Parameters:

`username` - The username

`password` - The password

Returns:

True in case the connection attempt was successful, false otherwise.

### connectWithKey

    Boolean connectWithKey(<String> username, <helma.File|java.io.File|String> key, <String> passphrase)

Connects to a remote host using a private key and the corresponding passphrase.

Parameters:

`username` - The username

`key` - Either a file object representing the private key file, or the path to it.

`passphrase` - The passphrase of the private key, if necessary.

Returns:

True in case the connection attempt was successful, false otherwise.

### disconnect

    void disconnect()

Disconnects this client from the remote server.

### execCommand

    String execCommand(<String> cmd)

Executes a single command on the remote server.

Parameters:

`cmd` - The command to execute on the remote server.

Returns:

The result of the command execution

### get

    Boolean get(<String|Array> remoteFile, <String> targetDir)

Retrieves a file from the remote server and stores it locally.

Parameters:

`remoteFile` - Either the path to a single remote file or an array containing multiple file paths that should be copied onto the local disk.

`targetDir` - The path to the local destination directory

Returns:

True if the copy process was successful, false otherwise.

### isConnected

    Boolean isConnected()

Returns true if this client is currently connected.

Returns:

True in case this client is connected, false otherwise.

### isParanoid

    Object isParanoid()

Returns true if this client is in paranoid mode.

Returns:

Boolean

See:

- setParanoid()

### put

    Boolean put(<String|Array> localFile, <String> remoteDir, <String> mode)

Copies a local file to the remote server

Parameters:

`localFile` - Either the path to a single local file or an array containing multiple file paths that should be copied to the remote server.

`remoteDir` - The path to the remote destination directory

`mode` - An optional 4-digit permission mode string (eg. `0755`);

Returns:

True in case the operation was successful, false otherwise.

### setParanoid

    void setParanoid(<Boolean> p)

Toggles paranoid mode. If set to true this client tries to verify the host key against the its list of known hosts during connection and rejects if the host key is not found therein or is different.

Parameters:

`p` - Either true or false

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Documentation generated by JSDoc on Thu Apr 5 01:59:00 2007