SSH@0 - SSH v0 工作

使用此工作,使用 SSH 在遠端電腦上執行殼層命令或腳本。 此工作可讓您使用 SSH 連線到遠端電腦,並執行命令或腳本。

Syntax

# 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.
# 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.

輸入

sshEndpoint - SSH 服務連線
string. 必要。

指定 SSH 服務連線的名稱,其中包含遠端電腦的連線詳細數據。 需要遠端電腦的主機名或IP位址、埠號碼和用戶名稱,才能建立SSH服務連線。

  • 必須指定私鑰和複雜密碼以進行驗證。
  • 密碼可用來向遠端 Linux 計算機進行驗證,但 macOS 或 Windows 系統不支援此密碼。

runOptions - 運行
string. 必要。 允許的值: commandsscript (腳本檔案) , inline (內嵌腳本) 。 預設值:commands

在遠端電腦上執行殼層命令或殼層腳本。


commands - 命令
string. 當 runOptions = commands 時為必要。

指定要在遠端電腦上執行的殼層命令。 只有在選取 [執行] 選項的 [命令] 時,才能使用此參數。 在多行文本框的新行上,輸入每個命令及其自變數。 若要一起執行多個命令,請在以分號分隔的相同行上輸入它們。 範例: cd /home/user/myFolder;build.

注意

每個命令都會在不同的進程中執行。 例如,如果您想要執行一系列相依 (的命令,請在執行命令) 之前變更目前資料夾,請改用 [內嵌腳本 ] 選項。


scriptPath - Shell 腳本路徑
string. 當 runOptions = script 時為必要。

指定要在遠端電腦上執行的殼層腳本檔案路徑。 只有在選取 [執行] 選項的Shell腳本時,才能使用此參數。


inline - 內嵌腳本
string. 當 runOptions = inline 時為必要。

寫入殼層腳本以在遠端電腦上執行。


interpreterCommand - 解釋器命令
string. 選擇性。 使用時機 runOptions = inline。 預設值:/bin/bash

指定用來執行文稿之命令解釋器的路徑。 在腳本的開頭新增一行耙耙。 僅適用於類似 UNIX 的作業系統。 針對以 Windows 為基礎的遠端主機使用空字串。 深入瞭解 (#!)


args - 參數
string. 選擇性。 使用時機 runOptions = script

指定要傳遞至殼層腳本的自變數。 只有在選取 [執行] 選項的Shell腳本時,才能使用此參數。


failOnStdErr - STDERR 失敗
boolean. 預設值:true

如果值為 true,當遠端命令或腳本寫入 至 STDERR時,建置會失敗。


interactiveSession - 啟用互動式會話
boolean. 預設值:false

啟動互動式會話。 密碼要求會由用戶的密碼填入。 互動式工作階段對於執行命令很有用,例如 sudo


readyTimeout - SSH 交握逾時
string. 必要。 預設值:20000

指定) 工作等候 SSH 交握完成的時間長度,以毫秒為單位 (。


interactiveKeyboardAuthentication - 使用互動式鍵盤驗證
boolean. 預設值:false

啟用互動式鍵盤驗證。 true如果您的目的地 SSH 伺服器需要互動式鍵盤驗證, (PasswordAuthentication 目標計算機/在sshd_config) 中设定为 [否]。


工作控制選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控件選項和一般工作屬性

輸出變數

無。

備註

使用此工作,使用 SSH 在遠端電腦上執行殼層命令或腳本。 此工作可讓您使用 SSH 連線到遠端電腦,並執行命令或腳本。

必要條件

  • 此工作支援使用 SSH 金鑰組連線到遠端電腦 () 。
  • 公鑰必須預安裝或複製到遠端電腦 () 。

支援的演算法

金鑰組演算法

  • RSA
  • DSA

加密演算法

  • aes256-cbc
  • aes192-cbc
  • aes128-cbc
  • fishfish-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、傳統組建、傳統版本
在上執行 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 2.206.1 或更新版本
工作類別 部署
需求 描述
管線類型 YAML、傳統組建、傳統版本
在上執行 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 2.144.0 或更新版本
工作類別 部署
需求 描述
管線類型 YAML、傳統組建、傳統版本
在上執行 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 2.102.0 或更新版本
工作類別 部署

另請參閱