Copy files and artifacts via SSH using a binary, docker or Drone CI.
  • Go 91.6%
  • Makefile 6.5%
  • Dockerfile 1.3%
  • Shell 0.6%
Find a file
Bo-Yi Wu 8d22a978c9
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Docker Image / build-docker (push) Waiting to run
Lint and Testing / lint (push) Waiting to run
Lint and Testing / testing (1.25) (push) Waiting to run
Lint and Testing / testing (1.26) (push) Waiting to run
Trivy Security Scan / Trivy Repository Scan (push) Waiting to run
Trivy Security Scan / Trivy Image Scan (push) Waiting to run
ci(actions): bump codecov-action from v6 to v7
- Update codecov/codecov-action from v6 to v7
2026-06-13 15:46:31 +08:00
.github ci(actions): bump codecov-action from v6 to v7 2026-06-13 15:46:31 +08:00
docker build: update dependencies and optimize Docker configuration 2025-03-10 22:17:06 +08:00
tests chore: support passphrase (#107) 2020-01-20 22:34:16 +08:00
.gitignore chore: standardize code style and enhance changelog configuration 2024-07-19 07:46:51 +08:00
.golangci.yaml ci: enhance linting and string manipulations in plugin code 2025-04-12 19:41:17 +08:00
.goreleaser.yaml chore: standardize code style and enhance changelog configuration 2024-07-19 07:46:51 +08:00
.hadolint.yaml chore: update Dockerfile and add .hadolint.yaml 2023-12-24 20:09:36 +08:00
bearer.yml feat(bearer): configure scanning and reporting settings 2024-12-01 17:47:06 +08:00
command.go feat: improve file handling with OS-specific functions and tests (#178) 2023-04-16 12:15:02 +08:00
command_test.go feat: improve file handling with OS-specific functions and tests (#178) 2023-04-16 12:15:02 +08:00
DOCS.md add woodpecker compatible metadata (#197) 2025-05-03 07:22:11 +08:00
go.mod chore: bump go directive to 1.25.10 2026-05-08 21:19:20 +08:00
go.sum fix(deps): upgrade golang.org/x/crypto to fix CVE vulnerabilities 2026-04-16 12:13:16 +08:00
LICENSE Initial commit 2016-10-16 21:35:56 +08:00
main.go feat: expand proxy configuration with new flags and env support 2025-04-27 11:41:44 +08:00
Makefile build: enhance build process and testing across environments 2025-04-15 10:35:36 +08:00
path.go chore(go1.18): build tag 2022-06-15 15:29:09 +08:00
path_windows.go refactor: improve code clarity and testing reliability across modules 2025-04-12 19:42:12 +08:00
path_windows_test.go chore: update build tag 2019-05-11 16:34:36 +08:00
plugin.go ci: enhance linting and string manipulations in plugin code 2025-04-12 19:41:17 +08:00
plugin_test.go test: enhance SCP plugin with folder ignore and error handling (#192) 2024-06-01 12:33:11 +08:00
README.md ci: add Trivy security scanning for source code and Docker image 2026-04-16 18:10:11 +08:00
README.zh-cn.md docs: improve consistency and accuracy of Chinese language selection 2025-08-31 11:06:02 +08:00
README.zh-tw.md docs: improve consistency and accuracy of Chinese language selection 2025-08-31 11:06:02 +08:00

drone-scp

繁體中文 | 簡體中文

GoDoc Lint and Testing Trivy Security Scan codecov Go Report Card Docker Pulls

Securely transfer files and artifacts via SSH using a standalone binary, Docker container, or Drone CI integration.

Features

  • Parallel file transfer with multiple routines
  • Support for wildcard patterns in source file selection
  • Ability to transfer files to multiple destination hosts
  • Support for multiple target directories on each host
  • Flexible SSH key authentication via file path or raw content
  • Advanced networking with SSH ProxyCommand support
+--------+       +----------+      +-----------+
| Laptop | <-->  | Jumphost | <--> | FooServer |
+--------+       +----------+      +-----------+

                   OR

+--------+       +----------+      +-----------+
| Laptop | <-->  | Firewall | <--> | FooServer |
+--------+       +----------+      +-----------+
192.168.1.5       121.1.2.3         10.10.29.68

Breaking changes

v1.5.0: change command timeout flag to Duration. See the following setting:

  - name: scp files
    image: appleboy/drone-scp
    settings:
      host:
        - example1.com
        - example2.com
      username: ubuntu
      password:
        from_secret: ssh_password
      port: 22
-     command_timeout: 120
+     command_timeout: 2m
      target: /home/deploy/web
      source:
        - release/*.tar.gz

Build or Download a binary

The pre-compiled binaries can be downloaded from release page. Support the following OS type.

  • Windows amd64/386
  • Linux arm/amd64/386
  • Darwin amd64/386

With Go installed

export GO111MODULE=on
go get -u -v github.com/appleboy/drone-scp

or build the binary with the following command:

export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on

go test -cover ./...

go build -v -a -tags netgo -o release/linux/amd64/drone-scp .

Docker

Build the docker image with the following commands:

make docker

Usage

There are three ways to send notification.

Usage from binary

Using public key

drone-scp --host example.com \
  --port 22 \
  --username appleboy \
  --key-path "${HOME}/.ssh/id_rsa" \
  --target /home/appleboy/test \
  --source your_local_folder_path

Using password

drone-scp --host example.com \
  --port 22 \
  --username appleboy \
+ --password xxxxxxx \
  --target /home/appleboy/test \
  --source your_local_folder_path

Using ssh-agent

Start your local ssh agent:

eval `ssh-agent -s`

Import your local public key ~/.ssh/id_rsa

ssh-add

You don't need to add --password or --key-path arguments.

drone-scp --host example.com \
  --port 22 \
  --username appleboy \
  --target /home/appleboy/test \
  --source your_local_folder_path

Send multiple source or target folder and hosts

drone-scp --host example1.com \
+ --host example2.com \
  --port 22 \
  --username appleboy \
  --password  xxxxxxx
  --target /home/appleboy/test1 \
+ --target /home/appleboy/test2 \
  --source your_local_folder_path_1
+ --source your_local_folder_path_2

Usage from docker

Using public key

docker run --rm \
  -e SCP_HOST=example.com \
  -e SCP_USERNAME=xxxxxxx \
  -e SCP_PORT=22 \
  -e SCP_KEY_PATH="${HOME}/.ssh/id_rsa"
  -e SCP_SOURCE=SOURCE_FILE_LIST \
  -e SCP_TARGET=TARGET_FOLDER_PATH \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

Using password

docker run --rm \
  -e SCP_HOST=example.com \
  -e SCP_USERNAME=xxxxxxx \
  -e SCP_PORT=22 \
+ -e SCP_PASSWORD="xxxxxxx"
  -e SCP_SOURCE=SOURCE_FILE_LIST \
  -e SCP_TARGET=TARGET_FOLDER_PATH \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

Using ssh-agent, start your local ssh agent:

eval `ssh-agent -s`

Import your local public key ~/.ssh/id_rsa

ssh-add

You don't need to add SCP_PASSWORD or SCP_KEY_PATH arguments.

docker run --rm \
  -e SCP_HOST=example.com \
  -e SCP_USERNAME=xxxxxxx \
  -e SCP_PORT=22 \
  -e SCP_SOURCE=SOURCE_FILE_LIST \
  -e SCP_TARGET=TARGET_FOLDER_PATH \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

Send multiple source or target folder and hosts

docker run --rm \
  -e SCP_HOST=example1.com,example2.com \
  -e SCP_USERNAME=xxxxxxx \
  -e SCP_PASSWORD=xxxxxxx \
  -e SCP_PORT=22 \
  -e SCP_SOURCE=SOURCE_FILE_LIST_1,SOURCE_FILE_LIST_2 \
  -e SCP_TARGET=TARGET_FOLDER_PATH_1,TARGET_FOLDER_PATH_2 \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

Usage from drone ci

Execute from the working directory:

docker run --rm \
  -e PLUGIN_HOST=example.com \
  -e PLUGIN_USERNAME=xxxxxxx \
  -e PLUGIN_PASSWORD=xxxxxxx \
  -e PLUGIN_PORT=xxxxxxx \
  -e PLUGIN_SOURCE=SOURCE_FILE_LIST \
  -e PLUGIN_TARGET=TARGET_FOLDER_PATH \
  -e PLUGIN_RM=false \
  -e PLUGIN_DEBUG=true \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

You can get more information about how to use scp in drone.

Testing

Test the package with the following command:

make test