Поделиться через


SSH Deployment task

TFS 2017

Use this task to run shell commands or a script on a remote machine using SSH. This task enables you to connect to a remote machine using SSH and run commands or a script.

Note

In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

Prerequisites

  • The task supports use of an SSH key pair to connect to the remote machine(s).
  • The public key must be pre-installed or copied to the remote machine(s).

Arguments

Argument Description
SSH endpoint The name of an SSH service connection containing connection details for the remote machine. The hostname or IP address of the remote machine, the port number, and the user name are required to create an SSH service connection.
- The private key and the passphrase must be specified for authentication.
- A password can be used to authenticate to remote Linux machines, but this is not supported for macOS or Windows systems.
Run Choose to run either shell commands or a shell script on the remote machine.
Commands The shell commands to run on the remote machine. This parameter is available only when Commands is selected for the Run option. Enter each command together with its arguments on a new line of the multi-line textbox. To run multiple commands together, enter them on the same line separated by semicolons. Example: cd /home/user/myFolder;build

NOTE: Each command runs in a separate process. If you want to run a series of commands that are interdependent (for example, changing the current folder before executing a command) use the Inline Script option instead.
Shell script path Path to the shell script file to run on the remote machine. This parameter is available only when Shell script is selected for the Run option.
Interpreter command Path to the command interpreter used to execute the script. Used when Run option = Inline. Adds a shebang line to the beginning of the script. Relevant only for UNIX-like operating systems. Please use empty string for Windows-based remote hosts. See more about shebang (#!)
Arguments The arguments to pass to the shell script. This parameter is available only when Shell script is selected for the Run option.
Advanced - Fail on STDERR If this option is selected (the default), the build will fail if the remote commands or script write to STDERR.
Control options See Control options

Supported algorithms

Key pair algorithms

  • RSA
  • DSA

Encryption algorithms

  • aes256-cbc
  • aes192-cbc
  • aes128-cbc
  • blowfish-cbc
  • 3des-cbc
  • arcfour256
  • arcfour128
  • cast128-cbc
  • arcfour

For OpenSSL v1.0.1 and higher (on agent):

  • aes256-ctr
  • aes192-ctr
  • aes128-ctr

For OpenSSL v1.0.1 and higher, NodeJS v0.11.12 and higher (on agent):

  • aes128-gcm
  • aes128-gcm@openssh.com
  • aes256-gcm
  • aes256-gcm@openssh.com

See also

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

FAQ

What key formats are supported for the SSH tasks?

The Azure Pipelines SSH tasks use the Node.js ssh2 package for SSH connections. Ensure that you are using the latest version of the SSH tasks. Older versions may not support the OpenSSH key format.

If you run into an "Unsupported key format" error, then you may need to add the -m PEM flag to your ssh-keygen command so that the key is in a supported format.

Do I need an agent?

You need at least one agent to run your build or release.

I'm having problems. How can I troubleshoot them?

See Troubleshoot Build and Release.

I can't select a default agent pool and I can't queue my build or release. How do I fix this?

See Agent pools.

My NuGet push task is failing with the following error: "Error: unable to get local issuer certificate". How can I fix this?

This can be fixed by adding a trusted root certificate. You can either add the NODE_EXTRA_CA_CERTS=file environment variable to your build agent, or you can add the NODE.EXTRA.CA.CERTS=file task variable in your pipeline. See Node.js documentation for more details about this variable. See Set variables in a pipeline for instructions on setting a variable in your pipeline.

I use TFS on-premises and I don't see some of these features. Why not?

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.