SSH@0 - SSH v0 工作
使用此工作在遠端電腦上使用 SSH 執行殼層命令或腳稿。 此工作可讓您使用 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 服務連線的名稱,其中包含遠端電腦的連線詳細數據。 需要遠端電腦的主機名或IP位址、埠號碼和用戶名稱,才能建立SSH服務連線。
- 必須指定私鑰和複雜密碼進行驗證。
- 密碼可用來向遠端 Linux 機器進行驗證,但 macOS 或 Windows 系統不支援此密碼。
runOptions
-
執行
string
。 必須的。 允許的值:commands
、script
(腳本檔案)、inline
(內嵌腳本)。 預設值:commands
。
在遠端電腦上執行殼層命令或殼層腳本。
commands
-
命令
string
。
runOptions = commands
時為必要項。
指定要在遠端電腦上執行的殼層命令。 只有在選取 [執行] 選項的 [命令] 時,才能使用此參數。 在多行文本框的新行上,輸入每個命令及其自變數。 若要一起執行多個命令,請在以分號分隔的相同行上輸入它們。 範例: cd /home/user/myFolder;build
.
備註
每個命令都會在不同的進程中執行。 如果您想要執行一系列相互相依的命令(例如,在執行命令之前變更目前的資料夾),請改用 Inline Script 選項。
scriptPath
-
Shell 腳本路徑
string
。
runOptions = script
時為必要項。
指定要在遠端電腦上執行的殼層腳本檔案路徑。 只有在選取 [執行] 選項的殼層腳本 時,才能使用此參數。
inline
-
內嵌腳本
string
。
runOptions = inline
時為必要項。
撰寫殼層腳本以在遠端電腦上執行。
interpreterCommand
-
解釋器命令
string
。 選擇性。
runOptions = inline
時使用 。 預設值:/bin/bash
。
指定用來執行文稿之命令解釋器的路徑。 將謝邦行新增至腳本的開頭。 僅適用於類似 UNIX 的作系統。 針對 Windows 型遠端主機使用空字串。 深入瞭解 謝邦(#!)。
args
-
自變數
string
。 選擇性。
runOptions = script
時使用 。
指定要傳遞至殼層腳本的自變數。 只有在選取 [執行] 選項的殼層腳本 時,才能使用此參數。
STDERR上的 failOnStdErr
- 失敗
boolean
。 預設值:true
。
如果值 true
,當遠端命令或腳本寫入至 STDERR
時,組建會失敗。
interactiveSession
-
啟用互動式會話
boolean
。 預設值:false
。
啟動互動式會話。 密碼要求會由用戶的密碼填入。 互動式工作階段對於執行命令很有用,例如 sudo
。
readyTimeout
-
SSH 交握逾時
string
。 必須的。 預設值:20000
。
指定工作等候 SSH 交握完成的時間長度(以毫秒為單位)。
interactiveKeyboardAuthentication
-
使用互動式鍵盤驗證
boolean
。 預設值:false
。
啟用互動式鍵盤驗證。 如果您的目的地 SSH 伺服器需要互動式鍵盤驗證,請將 設定為 true
(目標計算機上已停用PasswordAuthentication
/在 sshd_config 中設定為 [否]。
工作控制選項
除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制項選項和一般工作屬性。
輸出變數
沒有。
備註
使用此工作在遠端電腦上使用 SSH 執行殼層命令或腳稿。 此工作可讓您使用 SSH 連線到遠端電腦,並執行命令或腳本。
先決條件
- 工作支援使用 SSH 金鑰組來連線到遠端電腦。
- 公鑰必須預安裝或複製到遠端電腦。
支援的演算法
金鑰組演算法
- 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、傳統組建、傳統版本 |
執行於 | Agent、DeploymentGroup |
需求 | 沒有 |
功能 | 此工作不符合作業中後續工作的任何需求。 |
命令限制 | 任意 |
Settable 變數 | 任意 |
代理程式版本 | 2.206.1 或更新 |
工作類別 | 部署 |
要求 | 說明 |
---|---|
管線類型 | YAML、傳統組建、傳統版本 |
執行於 | Agent、DeploymentGroup |
需求 | 沒有 |
功能 | 此工作不符合作業中後續工作的任何需求。 |
命令限制 | 任意 |
Settable 變數 | 任意 |
代理程式版本 | 2.144.0 或更新 |
工作類別 | 部署 |
要求 | 說明 |
---|---|
管線類型 | YAML、傳統組建、傳統版本 |
執行於 | Agent、DeploymentGroup |
需求 | 沒有 |
功能 | 此工作不符合作業中後續工作的任何需求。 |
命令限制 | 任意 |
Settable 變數 | 任意 |
代理程式版本 | 2.102.0 或更新 |
工作類別 | 部署 |
另請參閱
- 安裝 SSH 金鑰工作
- 透過 SSH 複製檔案
- SSH 建置工作 部落格文章