SSH Session

Description

The com.dovetail.ant.ssh.SSHSession task is based on the optional Ant SSHSession task, version 1.9.8. It includes the following enhancements:

A Task which establishes an SSH connection with a remote machine running SSH daemon, optionally establishes any number of local or remote tunnels over that connection, then executes any nested tasks before taking down the connection.

Note: This task is used as an antlib with external libraries that are distributed with the Dovetail ant-ssh distribution.

See also the ssh exec task, the sftp task, and the scp task

Parameters

Attribute Description Required
host The hostname or IP address of the remote host to which you wish to connect. Yes
username The username on the remote host to which you are connecting. Yes
port The port to connect to on the remote host. No, defaults to 22.
localtunnels A comma-delimited list of colon-delimited lport:rhost:rport triplets defining local port forwarding.
If nested localtunnel elements are also provided, both sets of tunnels will be established.
No
remotetunnels A comma-delimited list of colon-delimited rport:lhost:lport triplets defining remote port forwarding.
If nested remotetunnel elements are also provided, both sets of tunnels will be established.
No
trust This trusts all unknown hosts if set to yes/true.
Note If you set this to false (the default), the host you connect to must be listed in your knownhosts file, this also implies that the file exists.
No, defaults to No.
knownhosts This sets the list of known hosts file(s) to use to validate the identity of the remote host. This must be a SSH2 format file. SSH1 format is not supported. The special file name "putty" may be used to refer to PuTTY host keys stored in the Windows registry. The first known hosts file in this list will be updated with a new host key if trust=yes. A mismatched host key will never be replaced with a new key. No, defaults to "putty,${user.home}/.ssh/known_hosts" on Windows if PuTTY is installed or "${user.home}/.ssh/known_hosts" otherwise. On non-Windows systems, the default is "${user.home}/.ssh/known_hosts,/etc/ssh_known_hosts". Dovetail enhancement
failonerror Whether to halt the build if the command does not complete successfully. No; defaults to true.
password The password. No.
keyfile Location of the file holding the private key. Yes, if you are using key based authentication.
passphrase Passphrase for your private key. No, defaults to an empty string.
useAgent Determines whether an ssh-agent or PuTTY agent (Windows) will be used for user key creditials. No, defaults to true if an SSH key agent is available. Dovetail enhancement, requires jsch agentyproxy and jna library jars
allowPasswordPrompt If password is not set, set this to No to prevent a password prompt. No, defaults to true if a password or keyfile or agent key is not supplied. Dovetail enhancement
sshVerbose Determines whether verbose messages from the JSch ssh library are output. Dovetail enhancement No; defaults to false.
timeout Give up if the connection cannot be established within the specified time (given in milliseconds). Defaults to 0 which means "wait forever". No

Parameters specified as nested elements

localtunnel

Optionally, any number of localtunnel elements can be used to define local port forwarding over the SSH connection. If the localtunnels parameter was also specified, both sets of tunnels will be established.

Attribute Description Required
lport The number of the local port to be forwarded. Yes
rhost The hostname or IP address of the remote host to which the local port should be forwarded. Yes
rport The number of the port on the remote host to which the local port should be forwarded. Yes

remotetunnel

Optionally, any number of remotetunnel elements can be used to define remote port forwarding over the SSH connection. If the remotetunnels parameter was also specified, both sets of tunnels will be established.

Attribute Description Required
rport The number of the remote port to be forwarded. Yes
lhost The hostname or IP address of the local host to which the remote port should be forwarded. Yes
lport The number of the port on the local host to which the remote port should be forwarded. Yes

sequential

The sequential element is a required parameter. It is a container for nested Tasks which are to be executed once the SSH connection is established and all local and/or remote tunnels established.

Examples

See Ant SSHSession Task for examples on using the original task.

See Sftp Task examples which use this task.