SSH@0 - SSH v0 任务

使用此任务可以使用 SSH 在远程计算机上运行 shell 命令或脚本。 通过此任务,可以使用 SSH 连接到远程计算机,并运行命令或脚本。

语法

# SSH v0
# Run shell commands or a script on a remote machine using SSH.
- task: SSH@0
  inputs:
    sshEndpoint: # string. Required. SSH service connection. 
    runOptions: 'commands' # 'commands' | 'script' | 'inline'. Required. Run. Default: commands.
    commands: # string. Required when runOptions = commands. Commands. 
    #scriptPath: # string. Required when runOptions = script. Shell script path. 
    #inline: # string. Required when runOptions = inline. Inline Script. 
    #interpreterCommand: '/bin/bash' # string. Optional. Use when runOptions = inline. Interpreter command. Default: /bin/bash.
    #args: # string. Optional. Use when runOptions = script. Arguments. 
  # Advanced
    #failOnStdErr: true # boolean. Fail on STDERR. Default: true.
    #interactiveSession: false # boolean. Enable interactive session. Default: false.
    readyTimeout: '20000' # string. Required. SSH handshake timeout. Default: 20000.
    #interactiveKeyboardAuthentication: false # boolean. Use interactive-keyboard authentication. Default: false.
# SSH v0
# Run shell commands or a script on a remote machine using SSH.
- task: SSH@0
  inputs:
    sshEndpoint: # string. Required. SSH service connection. 
    runOptions: 'commands' # 'commands' | 'script' | 'inline'. Required. Run. Default: commands.
    commands: # string. Required when runOptions = commands. Commands. 
    #scriptPath: # string. Required when runOptions = script. Shell script path. 
    #inline: # string. Required when runOptions = inline. Inline Script. 
    #interpreterCommand: '/bin/bash' # string. Optional. Use when runOptions = inline. Interpreter command. Default: /bin/bash.
    #args: # string. Optional. Use when runOptions = script. Arguments. 
  # Advanced
    #failOnStdErr: true # boolean. Fail on STDERR. Default: true.
    #interactiveSession: false # boolean. Enable interactive session. Default: false.
    readyTimeout: '20000' # string. Required. SSH handshake timeout. Default: 20000.
# SSH v0
# Run shell commands or a script on a remote machine using SSH.
- task: SSH@0
  inputs:
    sshEndpoint: # string. Required. SSH service connection. 
    runOptions: 'commands' # 'commands' | 'script' | 'inline'. Required. Run. Default: commands.
    commands: # string. Required when runOptions = commands. Commands. 
    #scriptPath: # string. Required when runOptions = script. Shell script path. 
    #inline: # string. Required when runOptions = inline. Inline Script. 
    #args: # string. Optional. Use when runOptions = script. Arguments. 
  # Advanced
    #failOnStdErr: true # boolean. Fail on STDERR. Default: true.
    readyTimeout: '20000' # string. Required. SSH handshake timeout. Default: 20000.

输入

sshEndpoint - SSH 服务连接
string。 必填。

指定 SSH 服务连接的名称,其中包含远程计算机的连接详细信息。 创建 SSH 服务连接需要远程计算机的主机名或 IP 地址、端口号和用户名。

  • 必须为身份验证指定私钥和通行短语。
  • 密码可用于向远程 Linux 计算机进行身份验证,但 macOS 或 Windows 系统不支持此密码。

runOptions - 运行
string。 必填。 允许的值:commandsscript(脚本文件)、inline(内联脚本)。 默认值:commands

在远程计算机上运行 shell 命令或 shell 脚本。


commands - 命令
stringrunOptions = commands时是必需的。

指定要在远程计算机上运行的 shell 命令。 仅当为 运行 选项选择 命令 时,此参数才可用。 在多行文本框的新行上输入每个命令及其参数。 若要一起运行多个命令,请在用分号分隔的同一行中输入它们。 示例:cd /home/user/myFolder;build

注释

每个命令在单独的进程中运行。 如果要运行一系列相互依赖的命令(例如,在执行命令之前更改当前文件夹),请改用 内联脚本 选项。


scriptPath - Shell 脚本路径
stringrunOptions = script时是必需的。

指定要在远程计算机上运行的 shell 脚本文件的路径。 仅当为 运行 选项选择了 Shell 脚本 时,此参数才可用。


inline - 内联脚本
stringrunOptions = inline时是必需的。

编写 shell 脚本以在远程计算机上运行。


interpreterCommand - 解释器命令
string。 可选。 当 runOptions = inline时使用。 默认值:/bin/bash

指定用于执行脚本的命令解释器的路径。 在脚本的开头添加一个 shebang 行。 仅适用于类似于 UNIX 的作系统。 对基于 Windows 的远程主机使用空字符串。 详细了解 谢邦(#!)


args - 参数
string。 可选。 当 runOptions = script时使用。

指定要传递给 shell 脚本的参数。 仅当为 运行 选项选择了 Shell 脚本 时,此参数才可用。


STDERR上的 failOnStdErr - 失败
boolean。 默认值:true

如果值为 true,则当远程命令或脚本写入 STDERR时,生成将失败。


interactiveSession - 启用交互式会话
boolean。 默认值:false

启动交互式会话。 密码请求由用户的密码填充。 交互式会话可用于运行命令,例如 sudo


readyTimeout - SSH 握手超时
string。 必填。 默认值:20000

指定任务等待 SSH 握手完成的时间(以毫秒为单位)。


interactiveKeyboardAuthentication - 使用交互式键盘身份验证
boolean。 默认值:false

启用交互式键盘身份验证。 如果目标 SSH 服务器需要交互式键盘身份验证,则设置为 true(目标计算机上禁用PasswordAuthentication/在sshd_config中设置为“否”)。


任务控制选项

除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性

输出变量

没有。

注解

使用此任务可以使用 SSH 在远程计算机上运行 shell 命令或脚本。 通过此任务,可以使用 SSH 连接到远程计算机,并运行命令或脚本。

先决条件

  • 该任务支持使用 SSH 密钥对连接到远程计算机。
  • 公钥必须预安装或复制到远程计算机(s)。

支持的算法

密钥对算法

  • RSA
  • DSA

加密算法

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

对于 OpenSSL v1.0.1 及更高版本(在代理上):

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

对于 OpenSSL v1.0.1 及更高版本,NodeJS v0.11.12 及更高版本(在代理上):

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

要求

要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 没有
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 2.206.1 或更高版本
任务类别 部署
要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 没有
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 2.144.0 或更高版本
任务类别 部署
要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 没有
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 2.102.0 或更高版本
任务类别 部署

另请参阅