You can use the Bamboo SSH task to execute a SSH command on a remote computer as part of a Bamboo job.

You can use the SSH task to do such things as:

  • Calling database migration scripts 
  • Starting and stopping services
  • Anything you can run on the command line on a remote machine

See Configuring a deployment task for an overview of Bamboo deployment tasks.

To configure an SSH task:

  1. Navigate to the Tasks configuration tab for the job (this will be the default job if creating a new plan).
  2. Click the name of an existing SSH task, or click Add Task and then SSH Task to create a new task.
  3. Complete the following settings:
     

    Task DescriptionHelps you identify the purpose of the task.
    Disable this taskCheck, or clear, to selectively run this task.
    HostThe hostname or IP address of the remote server on which the SSH Command will be executed.
    Verify remote host fingerprint on connectEnter the host fingerprint to be verified. See below for more details.
    PortThe port number of the remote host that is used for the SSH connection. The default value is 22.
    UsernameThe username to use to connect to the remote host.
    Authentication TypePassword – the password associated with Username.
    Key without passphrase – browse to the SSH private key with which to authenticate with the remote host.
    Key with passphrase – browse to the SSH private key, and supply the passphrase, to use to authenticate with the remote host.
    SSH CommandThe shell command to execute on the remote host. You can only enter a single command here.
  4. Click Save.

Host fingerprint

You can determine the fingerprint for a host by running:

ssh-keygen -l -F <HOSTNAME>

The fingerprint is the part of the response shown in the screenshot below:

  • No labels

11 Comments

  1. Anonymous

    Would it be a nice feature to be able to set a base directory here from which the command will execute?

  2. Anonymous

    If you have a multi-line command, are the lines run in sequence?

  3. Anonymous

    Is there a plan to support multi-line command's?

    1. James Dumay

      You can just specify different commands on multiple lines.

  4. Odin Odin

    When executing commands through the SSH-task, the output from commands are only updated after each command line is executed. Is there any plans to change this behaviour so that the command ouput is shown in Bamboo's deployment log more regularly, i.e updated at a given interval?

  5. Alvaro GAreppe

    I need to run a command with sudo but I'm getting "sudo: sorry, you must have a tty to run sudo".

    To avoid this error and be able to run a sudo command I need to specify -t option to the ssh command. There is any way to do this ?

    1. James Dumay

      Hi Alvaro,

      I'm not sure what could be the problem here. Could you contact our support team? They would be better equipped to help you.

      Thanks
      James

      1. Frank

        exactly the same issue here...

  6. Anonymous

    Hi.

    How i can used variables in "SSH command" field?

    Thx

    1. NathanA

      Hi, what exactly are you trying to achieve? Can you provide a few more details?

      Cheers,

      Nathan

      1. Piotr Tomaszewski

        Same request here. I'd like to be able to put into the SSH command box something like:

        touch "${bamboo.build.number}.txt"

        Without it, the benefits of using bamboo deployments are very limited as we need to create a lot of environment-specific tasks.