Class: Ssh

helma.Ssh(server, hosts)

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/).

Constructor

new Ssh(server, hosts)

Creates a new instance of helma.Ssh
Parameters:
Name Type Description
server String The server to connect to
hosts helma.File | java.io.File | String Either a file containing a list of known hosts, or the path pointing to a file. This argument is optional.
Author:
Source:
Returns:
A newly created instance of helma.Ssh

Methods

addKnownHosts(file)

Opens the file passed as argument and adds the known hosts therein to the list of known hosts for this client.
Parameters:
Name Type Description
file helma.File | java.io.File | String Either a file object or the path to a file containing a list of known hosts
Source:
Returns:
True if adding the list was successful, false otherwise

connect(username, password)

Connects to a remote host using plain username/password authentication.
Parameters:
Name Type Description
username String The username
password String The password
Source:
Returns:
True in case the connection attempt was successful, false otherwise.

connectWithKey(username, key, passphrase)

Connects to a remote host using a private key and the corresponding passphrase.
Parameters:
Name Type Description
username String The username
key helma.File | java.io.File | String Either a file object representing the private key file, or the path to it.
passphrase String The passphrase of the private key, if necessary.
Source:
Returns:
True in case the connection attempt was successful, false otherwise.

disconnect()

Disconnects this client from the remote server.
Source:

execCommand(cmd)

Executes a single command on the remote server.
Parameters:
Name Type Description
cmd String The command to execute on the remote server.
Source:
Returns:
The result of the command execution

get(remoteFile, targetDir)

Retrieves a file from the remote server and stores it locally.
Parameters:
Name Type Description
remoteFile String | Array Either the path to a single remote file or an array containing multiple file paths that should be copied onto the local disk.
targetDir String The path to the local destination directory
Source:
Returns:
True if the copy process was successful, false otherwise.

isConnected()

Returns true if this client is currently connected.
Source:
Returns:
True in case this client is connected, false otherwise.

isParanoid()

Returns true if this client is in paranoid mode.
Source:
See:
Returns:
Boolean

put(localFile, remoteDir, mode)

Copies a local file to the remote server
Parameters:
Name Type Description
localFile String | Array Either the path to a single local file or an array containing multiple file paths that should be copied to the remote server.
remoteDir String The path to the remote destination directory
mode String An optional 4-digit permission mode string (eg. 0755);
Source:
Returns:
True in case the operation was successful, false otherwise.

setParanoid(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:
Name Type Description
p Boolean Either true or false
Source: