67 Commits

Author SHA1 Message Date
Bo-Yi Wu
6d1fc191a8 chore: add dependabot
Some checks failed
scp files / Build (push) Failing after 5s
2022-06-15 22:08:26 +08:00
Bo-Yi Wu
233f762873 fix(ssh): OpenSSH 8.8+ RSA keys incompatibility
See: https://github.com/appleboy/drone-scp/issues/130
2022-06-15 22:06:41 +08:00
Bo-Yi Wu
b3f8d37ead Update README.md 2022-02-24 11:13:59 +08:00
Bo-Yi Wu
f57f59fba9 chore(drone-scp): upgrade to 1.6.3
Some checks failed
scp files / Build (push) Failing after 4s
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-10-23 18:49:52 +08:00
Bo-Yi Wu
8a54b39459 chore: replace ADD with COPY 2021-02-13 10:57:10 +08:00
Dan Tsekhanskiy
eb319b796f Minor typo/grammar fixes (#48)
Thanks for making this action! Noticed a few grammar/typos when going through the README.
2021-02-01 11:41:29 +08:00
Bjørn Wikkeling
3c3575eb49 fixed typo (#44) 2020-12-26 06:35:19 +08:00
Bo-Yi Wu
edc8ec9139 chore: bump drone-scp to v1.6.2
Some checks failed
scp files / Build (push) Failing after 5s
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-06-15 16:04:17 +08:00
Bo-Yi Wu
167d6d7ff4 try the latest version
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-06-15 16:00:17 +08:00
Bo-Yi Wu
ecd6a3623b Create .env 2020-06-15 15:33:59 +08:00
Bo-Yi Wu
31b514c281 fix typo 2020-06-05 09:06:01 +08:00
Bo-Yi Wu
5924b2b6d4 Merge pull request #25 from appleboy/use_insecure_cipher
Some checks failed
scp files / Build (push) Failing after 4s
2020-05-24 14:33:16 +08:00
Bo-Yi Wu
a2fea1040d chore: bump drone-scp to v1.6.1 2020-05-24 14:26:07 +08:00
Bo-Yi Wu
8535291767 chore: add use insecure cipher flag
fix server offered: [diffie-hellman-group-exchange-sha256] error

See https://github.com/appleboy/scp-action/issues/15
2020-05-24 14:24:45 +08:00
Bo-Yi Wu
faff4f4218 chore: bump drone-scp to 1.6.0
Some checks failed
scp files / Build (push) Failing after 5s
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-05-22 09:47:12 +08:00
Bo-Yi Wu
ddd9176502 remove unused flag
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-05-22 09:45:56 +08:00
Bo-Yi Wu
326e14ddd1 docs: add fingerprint flag
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-05-22 09:44:56 +08:00
Bo-Yi Wu
0329cffdaa chore: remove fail job 2020-05-22 00:47:08 +08:00
Bo-Yi Wu
6df9245376 chore: add debug 2020-05-21 23:33:05 +08:00
Bo-Yi Wu
4df1959b05 chore: add debug 2020-05-21 23:30:27 +08:00
Bo-Yi Wu
1c43a9662a chore: test 2020-05-21 23:24:36 +08:00
Bo-Yi Wu
2949c755a2 Merge pull request #22 from appleboy/docs 2020-05-08 19:04:41 +08:00
Bo-Yi Wu
aefa39daef chore: Add limitation in readme 2020-05-08 19:04:16 +08:00
Bo-Yi Wu
2305e4000a upgrade drone-scp to 1.5.9
Some checks failed
scp files / Build (push) Failing after 4s
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-05-05 09:54:11 +08:00
Bo-Yi Wu
c51573a06a upgrade drone-scp to 1.5.8
Some checks failed
scp files / Build (push) Failing after 5s
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-05-04 12:44:33 +08:00
Bo-Yi Wu
d068cd7f84 Merge pull request #20 from appleboy/docs 2020-05-04 09:16:53 +08:00
Bo-Yi Wu
8ba3cfe760 docs: use with instead of env
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-05-04 09:12:47 +08:00
Bo-Yi Wu
1a6b426141 chore: upgrade drone-scp to 1.5.7
Some checks failed
scp files / Build (push) Failing after 4s
2020-04-16 22:25:52 +08:00
Bo-Yi Wu
8b3eebcc8d Merge pull request #11 from dbingham/fixTypo
Some checks failed
scp files / Build (push) Failing after 5s
Update to drone-scp 1.5.6
2020-02-27 11:19:51 +08:00
Daniel Bingham
861f2e0e7b Update to drone-scp 1.5.6
To pull in the fix for the typo related to proxy_paraphrase
2020-02-26 18:19:00 -08:00
Bo-Yi Wu
6971270956 Add rm default value. 2020-02-25 23:47:04 +08:00
Bo-Yi Wu
bac6c9e026 update rm default value 2020-02-25 23:46:08 +08:00
Bo-Yi Wu
b04405242e chore: improve ci workflow 2020-02-14 00:49:23 +08:00
Bo-Yi Wu
5cb36bda99 chore: add proxy setting
Some checks failed
scp files / Build (push) Failing after 4s
2020-01-20 23:08:15 +08:00
Bo-Yi Wu
6c5771fab8 chore: Add passphrase 2020-01-20 23:07:25 +08:00
Bo-Yi Wu
193fd4eaa9 chore: add passphrase testing 2020-01-20 22:51:17 +08:00
Bo-Yi Wu
a5de8af6d5 chore: update default timeout to 10 minutes
Some checks failed
scp files / Build (push) Failing after 4s
2019-11-30 23:17:05 +08:00
Bo-Yi Wu
671c934c80 Update README.md 2019-09-30 21:52:10 +08:00
Bo-Yi Wu
8da6e3d335 update docs
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-30 16:59:44 +08:00
Bo-Yi Wu
196ea3f88f chore(scp): default port is 22
Some checks failed
scp files / Build (push) Failing after 4s
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-30 16:58:33 +08:00
Bo-Yi Wu
034b0ad00c Update README.md 2019-09-30 11:38:02 +08:00
Bo-Yi Wu
95e250284b docs: update readme 2019-09-29 14:16:22 +08:00
Bo-Yi Wu
a593d18cb8 docs: add default value of timeout 2019-09-29 01:45:56 +08:00
Bo-Yi Wu
2e28e2ddc9 chore: bump drone-scp to 1.5.3
Some checks failed
scp files / Build (push) Failing after 6s
2019-09-29 01:43:03 +08:00
Bo-Yi Wu
f8189f0fbf chore(scp): add overwrite and tar_tmp_path 2019-09-29 01:42:21 +08:00
Bo-Yi Wu
722ddfc32b chore: upgrade to drone-scp:1.5.2
Some checks failed
scp files / Build (push) Failing after 7s
2019-09-28 12:55:25 +08:00
Bo-Yi Wu
e506e72e83 remove debug message
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:45:17 +08:00
Bo-Yi Wu
bd7b71696a debug
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:43:06 +08:00
Bo-Yi Wu
b1b9ed628c docs: update default value 2019-09-28 12:41:21 +08:00
Bo-Yi Wu
72fe6fa2ca add default value
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:39:28 +08:00
Bo-Yi Wu
f1b7ce641c update INPUT_STRIP_COMPONENTS
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:37:22 +08:00
Bo-Yi Wu
722d935a90 update INPUT_STRIP_COMPONENTS
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:34:38 +08:00
Bo-Yi Wu
6fd371aeaf docs: add example 2019-09-28 12:26:40 +08:00
Bo-Yi Wu
5138976c70 docs: add badge 2019-09-28 12:17:08 +08:00
Bo-Yi Wu
d322577e98 docs: update readme 2019-09-28 12:16:21 +08:00
Bo-Yi Wu
c0a815a115 docs: update readme. 2019-09-28 12:13:03 +08:00
Bo-Yi Wu
afd2e26f9f chore: copy file via ssh key 2019-09-28 12:01:18 +08:00
Bo-Yi Wu
2ef3f5e459 chore: check timeout variable 2019-09-28 11:40:28 +08:00
Bo-Yi Wu
f0de4fea6f chore: add default timeout 2019-09-28 11:37:34 +08:00
Bo-Yi Wu
03e93ae863 chore: update target 2019-09-28 11:32:50 +08:00
Bo-Yi Wu
bffdab6759 chore: update 2019-09-28 11:23:50 +08:00
Bo-Yi Wu
e22c039905 chore: checkout source code. 2019-09-28 11:15:01 +08:00
Bo-Yi Wu
44284b60e4 chore: add timeout flag 2019-09-28 11:10:11 +08:00
Bo-Yi Wu
b154adaf5c chore: copy file via ssh password 2019-09-28 10:54:49 +08:00
Bo-Yi Wu
a6224ab4f0 chore: add github actions config 2019-09-28 10:42:13 +08:00
Bo-Yi Wu
1a31789cbc chore: rename the worflow file 2019-09-28 10:32:00 +08:00
Bo-Yi Wu
74e3e1df58 docs: add args command helper. 2019-05-12 10:25:37 +08:00
7 changed files with 303 additions and 152 deletions

10
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly

65
.github/main.workflow vendored
View File

@@ -1,65 +0,0 @@
workflow "Copy File Via SSH" {
on = "push"
resolves = [
"Copy file via ssh password",
"Copy file via ssh key",
"Add source in args",
"Add secret in args",
]
}
action "Copy file via ssh password" {
uses = "appleboy/scp-action@master"
env = {
SOURCE = "tests/a.txt,tests/b.txt"
TARGET = "/home/actions/test"
}
secrets = [
"HOST",
"USERNAME",
"PASSWORD",
]
}
action "Copy file via ssh key" {
uses = "appleboy/scp-action@master"
env = {
SOURCE = "tests/a.txt,tests/b.txt"
TARGET = "/home/actions/test"
}
secrets = [
"HOST",
"USERNAME",
"KEY",
]
}
action "Add source in args" {
uses = "appleboy/scp-action@master"
env = {
TARGET = "/home/actions/test1234"
}
secrets = [
"HOST",
"USERNAME",
"KEY",
]
args = ["--source", "tests/a.txt", "--source", "tests/b.txt"]
}
action "Add secret in args" {
uses = "appleboy/scp-action@master"
env = {
TARGET = "/home/actions/test1234"
}
secrets = [
"HOST",
"TEST_USERNAME",
"KEY",
]
args = [
"--username", "$TEST_USERNAME",
"--source", "tests/a.txt",
"--source", "tests/b.txt",
]
}

64
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,64 @@
name: scp files
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v1
- name: copy file via ssh password
uses: ./
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
source: "tests/a.txt,tests/b.txt"
target: "test"
- name: copy file via ssh key
uses: ./
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: "tests/a.txt,tests/b.txt"
target: "test"
- name: remove the specified number of leading path elements
uses: ./
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: "tests/a.txt,tests/b.txt"
target: "foobar"
strip_components: 1
- name: ssh key with passphrase
uses: ./
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH2 }}
passphrase: ${{ secrets.PASSPHRASE }}
port: ${{ secrets.PORT }}
source: "tests/a.txt,tests/b.txt"
target: "test"
- name: use insecure cipher
uses: ./
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH2 }}
passphrase: ${{ secrets.PASSPHRASE }}
port: ${{ secrets.PORT }}
source: "tests/a.txt,tests/b.txt"
target: "test"
use_insecure_cipher: true

View File

@@ -1,16 +1,5 @@
FROM appleboy/drone-scp:1.5.1-linux-amd64
FROM appleboy/drone-scp:1.6.4-linux-amd64
# Github labels
LABEL "com.github.actions.name"="SCP Files"
LABEL "com.github.actions.description"="Copy files and artifacts via SSH"
LABEL "com.github.actions.icon"="copy"
LABEL "com.github.actions.color"="gray-dark"
LABEL "repository"="https://github.com/appleboy/scp-action"
LABEL "homepage"="https://github.com/appleboy"
LABEL "maintainer"="Bo-Yi Wu <appleboy.tw@gmail.com>"
LABEL "version"="0.0.1"
ADD entrypoint.sh /entrypoint.sh
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

221
README.md
View File

@@ -1,97 +1,172 @@
# 🚀 SCP for GitHub Actions
[GitHub Action](https://developer.github.com/actions/) for copying files and artifacts via SSH.
[GitHub Action](https://github.com/features/actions) for copying files and artifacts via SSH.
<img src="./images/copy-multiple-file.png">
[![Actions Status](https://github.com/appleboy/scp-action/workflows/scp%20files/badge.svg)](https://github.com/appleboy/scp-action/actions)
**Important**: Only support **Linux** [docker](https://www.docker.com/) container.
## Usage
copy files and artifacts via SSH as blow.
Copy files and artifacts via SSH:
```
action "Copy multiple file" {
uses = "appleboy/scp-action@master"
env = {
HOST = "example.com"
USERNAME = "foo"
PASSWORD = "bar"
PORT = "22"
SOURCE = "tests/a.txt,tests/b.txt"
TARGET = "/home/foo/test"
}
secrets = [
"PASSWORD",
]
}
```yaml
name: scp files
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: copy file via ssh password
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
source: "tests/a.txt,tests/b.txt"
target: "test"
```
## Environment variables
## Input variables
* HOST - ssh server host
* PORT - ssh server port
* USERNAME - ssh server username
* PASSWORD - ssh server password
* KEY - ssh server private key
* TARGET - target folder
* SOURCE - scp file list
See the [action.yml](./action.yml) file for more detail information.
* host - scp remote host
* port - scp remote port, default is `22`
* username - scp username
* password - scp password
* passphrase - the passphrase is usually to encrypt the private key
* fingerprint - fingerprint SHA256 of the host public key, default is to skip verification
* timeout - timeout for ssh to remote host, default is `30s`
* command_timeout - timeout for scp command, default is `10m`
* key - content of ssh private key. ex raw content of ~/.ssh/id_rsa
* key_path - path of ssh private key
* target - target path on the server
* source - scp file list
* rm - remove target folder before upload data, default is `false`
* strip_components - remove the specified number of leading path elements.
* overwrite - use `--overwrite` flag with tar
* tar_tmp_path - temporary path for tar file on the dest host
* use_insecure_cipher - include more ciphers with use_insecure_cipher (see [#15](https://github.com/appleboy/scp-action/issues/15))
SSH Proxy Setting:
* proxy_host - proxy host
* proxy_port - proxy port, default is `22`
* proxy_username - proxy username
* proxy_password - proxy password
* proxy_passphrase - the passphrase is usually to encrypt the private key
* proxy_timeout - timeout for ssh to proxy host, default is `30s`
* proxy_key - content of ssh proxy private key.
* proxy_key_path - path of ssh proxy private key
* proxy_fingerprint - fingerprint SHA256 of the host public key, default is to skip verification
* proxy_use_insecure_cipher - include more ciphers with use_insecure_cipher (see [#15](https://github.com/appleboy/scp-action/issues/15))
### Example
Copy file via ssh password
Copy file via a SSH password:
```
action "Copy multiple file" {
uses = "appleboy/scp-action@master"
env = {
HOST = "example.com"
USERNAME = "foo"
PORT = "22"
SOURCE = "tests/a.txt,tests/b.txt"
TARGET = "/home/foo/test"
}
secrets = [
"PASSWORD",
]
}
```yaml
- name: copy file via ssh password
uses: appleboy/scp-action@master
with:
host: example.com
username: foo
password: bar
port: 22
source: "tests/a.txt,tests/b.txt"
target: "test"
```
Copy file via ssh key
Copy file via a SSH key:
```
action "Copy file via ssh key" {
uses = "appleboy/scp-action@master"
env = {
HOST = "example.com"
USERNAME = "foo"
PORT = "22"
SOURCE = "tests/c.txt,tests/d.txt"
TARGET = "/home/actions/test"
}
secrets = [
"KEY",
]
}
```yaml
- name: copy file via ssh key
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.KEY }}
source: "tests/a.txt,tests/b.txt"
target: "test"
```
Example configuration for ignore list:
```
action "reqular expression list" {
uses = "appleboy/scp-action@master"
env = {
HOST = "example.com"
USERNAME = "foo"
PORT = "22"
SOURCE = "tests/*.txt,!tests/a.txt"
TARGET = "/home/actions/test"
}
secrets = [
"KEY",
]
}
```yaml
- name: copy file via ssh key
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.KEY }}
source: "tests/*.txt,!tests/a.txt"
target: "test"
```
## Secrets
Example configuration for multiple servers:
* `PASSWORD` - ssh server password
* `KEY` - ssh server private key
```diff
uses: appleboy/scp-action@master
with:
- host: "example.com"
+ host: "foo.com,bar.com"
username: foo
password: bar
port: 22
source: "tests/a.txt,tests/b.txt"
target: "test"
```
Remove the specified number of leading path elements:
```yaml
- name: remove the specified number of leading path elements
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
source: "tests/a.txt,tests/b.txt"
target: "foobar"
strip_components: 1
```
Old target structure:
```sh
foobar
└── tests
├── a.txt
└── b.txt
```
New target structure:
```sh
foobar
├── a.txt
└── b.txt
```
Protecting a Private Key. The purpose of the passphrase is usually to encrypt the private key. This makes the key file by itself useless to an attacker. It is not uncommon for files to leak from backups or decommissioned hardware, and hackers commonly exfiltrate files from compromised systems.
```diff
- name: ssh key with passphrase
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH2 }}
+ passphrase: ${{ secrets.PASSPHRASE }}
port: ${{ secrets.PORT }}
source: "tests/a.txt,tests/b.txt"
target: "test"
```

78
action.yml Normal file
View File

@@ -0,0 +1,78 @@
name: 'SCP Command to Transfer Files'
description: 'How to Use SCP Command to Transfer Files/Folders in Linux'
author: 'Bo-Yi Wu'
inputs:
host:
description: 'scp remote host'
port:
description: 'scp remote port'
default: 22
username:
description: 'scp username'
password:
description: 'scp password'
timeout:
description: 'timeout for ssh to remote host'
default: "30s"
command_timeout:
description: 'timeout for scp command'
default: "10m"
key:
description: 'content of ssh private key. ex raw content of ~/.ssh/id_rsa'
key_path:
description: 'path of ssh private key'
passphrase:
description: 'ssh key passphrase'
fingerprint:
description: 'fingerprint SHA256 of the host public key, default is to skip verification'
use_insecure_cipher:
description: 'include more ciphers with use_insecure_cipher'
default: false
target:
description: 'target path on the server'
source:
description: 'scp file list'
rm:
description: 'remove target folder before upload data'
default: false
debug:
description: 'enable debug message'
default: false
strip_components:
description: 'remove the specified number of leading path elements'
default: 0
overwrite:
description: 'use `--overwrite` flag with tar'
default: false
tar_tmp_path:
description: 'temporary path for tar file on the dest host'
proxy_host:
description: 'ssh proxy remote host'
proxy_port:
description: 'ssh proxy remote port'
default: 22
proxy_username:
description: 'ssh proxy username'
proxy_password:
description: 'ssh proxy password'
proxy_passphrase:
description: 'ssh proxy key passphrase'
proxy_timeout:
description: 'timeout for ssh to proxy host'
default: "30s"
proxy_key:
description: 'content of ssh proxy private key. ex raw content of ~/.ssh/id_rsa'
proxy_key_path:
description: 'path of ssh proxy private key'
proxy_fingerprint:
description: 'fingerprint SHA256 of the host public key, default is to skip verification'
proxy_use_insecure_cipher:
description: 'include more ciphers with use_insecure_cipher'
default: false
runs:
using: 'docker'
image: 'Dockerfile'
branding:
icon: 'copy'
color: 'gray-dark'

View File

@@ -2,6 +2,6 @@
set -eu
export GITHUB="true"
[ -n "$INPUT_STRIP_COMPONENTS" ] && export INPUT_STRIP_COMPONENTS=$((INPUT_STRIP_COMPONENTS + 0))
sh -c "/bin/drone-scp $*"