SSH

by appleboy

The example Yaml configurations in this file are using the legacy 0.8 syntax. If you are using Drone 1.0 or Drone Cloud please ensure you use the appropriate 1.0 syntax. Learn more here.

Use the SSH plugin to execute commands on a remote server. The below pipeline configuration demonstrates simple usage:

pipeline:
  ssh:
    image: appleboy/drone-ssh
    host: foo.com
    username: root
    password: 1234
    port: 22
    script:
      - echo hello
      - echo world

Example configuration in your .drone.yml file for multiple hosts:

pipeline:
  ssh:
    image: appleboy/drone-ssh
    host:
+    - foo.com
+    - bar.com
    username: root
    password: 1234
    port: 22
    script:
      - echo hello
      - echo world

Example configuration for command timeout (unit: second), default value is 60 seconds:

pipeline:
  ssh:
    image: appleboy/drone-ssh
    host: foo.com
    username: root
    password: 1234
    port: 22
+   command_timeout: 120
    script:
      - echo hello
      - echo world

Example configuration for execute commands on a remote server using `SSHProxyCommand`:

pipeline:
  ssh:
    image: appleboy/drone-ssh
    host: foo.com
    username: root
    password: 1234
    port: 22
    script:
      - echo hello
      - echo world
+   proxy_host: 10.130.33.145
+   proxy_user: ubuntu
+   proxy_port: 22
+   proxy_password: 1234

Example configuration using password from secrets:

pipeline:
  ssh:
    image: appleboy/drone-ssh
    host: foo.com
    username: root
-   password: 1234
    port: 22
+   secrets: [ ssh_password ]
    script:
      - echo hello
      - echo world

Example configuration using ssh key from secrets:

pipeline:
  ssh:
    image: appleboy/drone-ssh
    host: foo.com
    username: root
    port: 22
+   secrets: [ ssh_key ]
    script:
      - echo hello
      - echo world

Example configuration for exporting custom secrets:

pipeline:
  ssh:
    image: appleboy/drone-ssh
    host: foo.com
    username: root
    password: 1234
    port: 22
+   secrets: [ aws_access_key_id ]
+   envs: [ aws_access_key_id ]
    script:
      - export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID

Secret Reference

ssh_username
account for target host user
ssh_password
password for target host user
ssh_key
plain text of user private key
proxy_ssh_username
account for user of proxy server
proxy_ssh_password
password for user of proxy server
proxy_ssh_key
plain text of user private key for proxy server

Parameter Reference

host
target hostname or IP
port
ssh port of target host
username
account for target host user
password
password for target host user
key
plain text of user private key
key_path
key path of user private key
envs
custom secrets which are made available in the script section
script
execute commands on a remote server
timeout
Timeout is the maximum amount of time for the TCP connection to establish.
command_timeout
Command timeout is the maximum amount of time for the execute commands, default is 60 secs.
proxy_host
proxy hostname or IP
proxy_port
ssh port of proxy host
proxy_username
account for proxy host user
proxy_password
password for proxy host user
proxy_key
plain text of proxy private key
proxy_key_path
key path of proxy private key

这个网页有没有错误? 请让我们知道 或编辑 这个页面