次の方法で共有


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.

入力

SSH サービス接続sshEndpoint - する
string. 必須。

リモート コンピューターの接続の詳細を含む SSH サービス接続の名前を指定します。 SSH サービス接続を作成するには、リモート コンピューターのホスト名または IP アドレス、ポート番号、およびユーザー名が必要です。

  • 認証には秘密キーとパスフレーズを指定する必要があります。
  • パスワードを使用してリモート Linux マシンに対する認証を行うことができますが、これは macOS または Windows システムではサポートされていません。

runOptions - 実行
string. 必須。 使用できる値: commandsscript (スクリプト ファイル)、inline (インライン スクリプト)。 既定値: commands.

リモート コンピューターでシェル コマンドまたはシェル スクリプトを実行します。


commands - コマンド
string. runOptions = commandsする場合に必要です。

リモート コンピューターで実行するシェル コマンドを指定します。 このパラメーターは、実行 オプション コマンド が選択されている場合にのみ使用できます。 複数行テキスト ボックスの新しい行に、各コマンドとその引数を入力します。 複数のコマンドを一緒に実行するには、セミコロンで区切って同じ行にコマンドを入力します。 例: cd /home/user/myFolder;build

各コマンドは、個別のプロセスで実行されます。 相互に依存する一連のコマンドを実行する場合 (たとえば、コマンドを実行する前に現在のフォルダーを変更する場合)、代わりに インライン スクリプト オプションを使用します。


シェル スクリプト パスscriptPath - する
string. runOptions = scriptする場合に必要です。

リモート コンピューターで実行するシェル スクリプト ファイルへのパスを指定します。 このパラメーターは、実行 オプション シェル スクリプト が選択されている場合にのみ使用できます。


インライン スクリプト の
string. runOptions = inlineする場合に必要です。

リモート コンピューターで実行するシェル スクリプトを書き込みます。


interpreterCommand - インタープリター コマンド
string. 任意 runOptions = inlineするときに使用します。 既定値: /bin/bash.

スクリプトの実行に使用するコマンド インタープリターへのパスを指定します。 スクリプトの先頭に shebang 行を追加します。 UNIX に似たオペレーティング システムにのみ関連します。 Windows ベースのリモート ホストには空の文字列を使用します。 shebang (#!)の詳細を確認してください。


args - 引数
string. 任意 runOptions = scriptするときに使用します。

シェル スクリプトに渡す引数を指定します。 このパラメーターは、実行 オプション シェル スクリプト が選択されている場合にのみ使用できます。


STDERRでの failOnStdErr - の失敗
boolean. 既定値: true.

値が true場合、リモート コマンドまたはスクリプトが STDERRに書き込むときにビルドが失敗します。


interactiveSession - 対話型セッション を有効にする
boolean. 既定値: false.

対話型セッションを開始します。 パスワード要求は、ユーザーのパスワードによって入力されます。 対話型セッションは、sudoなどのコマンドを実行する場合に役立ちます。


SSH ハンドシェイク タイムアウトreadyTimeout -
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、クラシック ビルド、クラシック リリース
実行日 エージェント、DeploymentGroup
の需要 なし
機能の このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 どれでも
設定可能な変数 どれでも
エージェントのバージョン 2.206.1 以上
タスク カテゴリ 展開
要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
実行日 エージェント、DeploymentGroup
の需要 なし
機能の このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 どれでも
設定可能な変数 どれでも
エージェントのバージョン 2.144.0 以上
タスク カテゴリ 展開
要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
実行日 エージェント、DeploymentGroup
の需要 なし
機能の このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 どれでも
設定可能な変数 どれでも
エージェントのバージョン 2.102.0 以上
タスク カテゴリ 展開

こちらもご覧ください