Skip to content
derickbailey edited this page Aug 12, 2010 · 12 revisions

The SshTask allows you to execute commands against a remote system, using a Secure Shell connection.

How to use the SshTask

To use this task, you will need to have an ssh server set up on the remote machine that you wish to connect to and execute commands against. Setting that up is out of the scope of this documentation. You should be able to find plenty of information on how to do this via Google or your favorite search engine.
You can connect to an ssh server using a username/password pair or by providing a rsa key.

desc "Run a command against a remote machine using the username/password connection method"
ssh do |ssh|
  ssh.server = "my server"
  ssh.username = "some user"
  ssh.password = "don't tel! it's a secret!"
  ssh.commands "some command to execute", "another command"
end
desc "Run a command against a remote machine using the rsa key connection method"
ssh do |ssh|
  ssh.server = "my server"
  ssh.key = ... a rsa key
  ssh.commands "ls -l"
end

Configuration options

The following configuration options are available for the SshTask.

server (required)

This is the name of the remote machine to connect to. This can be an IP address or other type of connection name that resolves to the computer in question.

username (optional)

This is the user to log in as, on the remote machine. The command specified will be executed as this user.
You don’t need to set this attribute when using a rsa key.

password (optional)

This is the password used to log in as the user, on the remote machine.
Required when the username attribute is set.

key (optional)

This is the rsa key to log in on the remote machine.
You don’t need to provide it if you use usern/password identification method.

commands (required)

This is the list of commands that you wish to execute on the remote machine. For example, if you wish to run a specific executable with parameters on the remote machine, you may set up a command such as this:

ssh.commands "./some_software/dosomething.exe --options values"

You can append multiple commands to the .commands array and the ssh task will execute each one of them, sequentially.

Logging

The SshTask uses the built in logging options to log the command being executed and log the output of the remote command.

YAML configuration

This task supports configuration via an external YAML file. For more information, see the yamlconfig page.