Compare commits

..

No commits in common. "3d59448764c0f94f80ffcfea943710c44b75cb43" and "f042d742db5dd7c2fc7e588f36cf0558cd921638" have entirely different histories.

View File

@ -4,7 +4,7 @@
[![Actions Status](https://github.com/appleboy/scp-action/workflows/scp%20files/badge.svg)](https://github.com/appleboy/scp-action/actions) [![Actions Status](https://github.com/appleboy/scp-action/workflows/scp%20files/badge.svg)](https://github.com/appleboy/scp-action/actions)
**Important**: Only supports **Linux** [docker](https://www.docker.com/) containers. **Important**: Only support **Linux** [docker](https://www.docker.com/) container.
## Usage ## Usage
@ -14,6 +14,7 @@ Copy files and artifacts via SSH:
name: scp files name: scp files
on: [push] on: [push]
jobs: jobs:
build: build:
name: Build name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -34,50 +35,46 @@ jobs:
See the [action.yml](./action.yml) file for more detail information. See the [action.yml](./action.yml) file for more detail information.
| Variable | Description | Default Value | * host - scp remote host
| ------------------- | ----------------------------------------------------------------------------------------------------------- | ------------- | * port - scp remote port, default is `22`
| host | SCP remote host | - | * username - scp username
| port | SCP remote port | `22` | * password - scp password
| username | SCP username | - | * passphrase - the passphrase is usually to encrypt the private key
| password | SCP password | - | * protocol - The IP protocol to use. Valid values are `tcp`. `tcp4` or `tcp6`. Default to `tcp`.
| passphrase | The passphrase is usually used to encrypt the private key | - | * fingerprint - fingerprint SHA256 of the host public key, default is to skip verification
| protocol | The IP protocol to use. Valid values are `tcp`, `tcp4`, or `tcp6`. | `tcp` | * timeout - timeout for ssh to remote host, default is `30s`
| fingerprint | Fingerprint SHA256 of the host public key. Default is to skip verification | - | * command_timeout - timeout for scp command, default is `10m`
| timeout | Timeout for SSH to remote host | `30s` | * key - content of ssh private key. ex raw content of ~/.ssh/id_rsa
| command_timeout | Timeout for SCP command | `10m` | * key_path - path of ssh private key
| key | Content of SSH private key. e.g., raw content of ~/.ssh/id_rsa | - | * target - target path on the server, must be a directory (**required**)
| key_path | Path of SSH private key | - | * source - scp file list (**required**)
| target | Target path on the server, must be a directory (**required**) | - | * rm - remove target folder before upload data, default is `false`
| source | SCP file list (**required**) | - | * strip_components - remove the specified number of leading path elements.
| rm | Remove target folder before uploading data | `false` | * overwrite - use `--overwrite` flag with tar, overwrite existing files when extracting
| strip_components | Remove the specified number of leading path elements | - | * tar_tmp_path - temporary path for tar file on the dest host
| overwrite | Use `--overwrite` flag with tar, overwrite existing files when extracting | - | * tar_exec - path to tar executable on the dest host. default is `tar`
| tar_tmp_path | Temporary path for tar file on the destination host | - | * tar_dereference - use `--dereference` flag with tar, follow symlinks; archive and dump the files they point to
| tar_exec | Path to tar executable on the destination host | `tar` | * use_insecure_cipher - include more ciphers with use_insecure_cipher (see [#15](https://github.com/appleboy/scp-action/issues/15))
| tar_dereference | Use `--dereference` flag with tar, follow symlinks; archive and dump the files they point to | - |
| use_insecure_cipher | Include more ciphers with use_insecure_cipher (see [#15](https://github.com/appleboy/scp-action/issues/15)) | - |
SSH Proxy Setting: SSH Proxy Setting:
| Variable | Description | Default Value | * proxy_host - proxy host
| ------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------- | * proxy_port - proxy port, default is `22`
| proxy_host | Proxy host | - | * proxy_username - proxy username
| proxy_port | Proxy port | `22` | * proxy_password - proxy password
| proxy_username | Proxy username | - | * proxy_protocol - The IP protocol to use. Valid values are `tcp`. `tcp4` or `tcp6`. Default to `tcp`.
| proxy_password | Proxy password | - | * proxy_passphrase - the passphrase is usually to encrypt the private key
| proxy_protocol | The IP protocol to use. Valid values are `tcp`, `tcp4`, or `tcp6`. | `tcp` | * proxy_timeout - timeout for ssh to proxy host, default is `30s`
| proxy_passphrase | The passphrase is usually used to encrypt the private key | - | * proxy_key - content of ssh proxy private key.
| proxy_timeout | Timeout for SSH to proxy host | `30s` | * proxy_key_path - path of ssh proxy private key
| proxy_key | Content of SSH proxy private key | - | * proxy_fingerprint - fingerprint SHA256 of the host public key, default is to skip verification
| proxy_key_path | Path of SSH proxy private key | - | * proxy_use_insecure_cipher - include more ciphers with use_insecure_cipher (see [#15](https://github.com/appleboy/scp-action/issues/15))
| 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)) | - |
## Setting up a SSH Key ## Setting up a SSH Key
Make sure to follow the steps below when creating and using SSH keys. Make sure to follow the below steps while creating SSH Keys and using them.
The best practice is to create the SSH keys on the local machine, not the remote machine. The best practice is create the SSH Keys on local machine not remote machine.
Log in with the username specified in GitHub Secrets and generate an RSA key pair: Login with username specified in Github Secrets. Generate a RSA Key-Pair:
```bash ```bash
# rsa # rsa
@ -111,9 +108,9 @@ See the detail information about [SSH login without password](http://www.linuxpr
**A note** from one of our readers: Depending on your version of SSH you might also have to do the following changes: **A note** from one of our readers: Depending on your version of SSH you might also have to do the following changes:
- Put the public key in `.ssh/authorized_keys2` * Put the public key in `.ssh/authorized_keys2`
- Change the permissions of `.ssh` to 700 * Change the permissions of `.ssh` to 700
- Change the permissions of `.ssh/authorized_keys2` to 640 * Change the permissions of `.ssh/authorized_keys2` to 640
### If you are using OpenSSH ### If you are using OpenSSH
@ -152,20 +149,6 @@ Copy file via a SSH password:
target: your_server_target_folder_path target: your_server_target_folder_path
``` ```
Using the environment variables
```yaml
- name: copy file via ssh password
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ env.PORT }}
source: "tests/a.txt,tests/b.txt"
target: ${{ env.TARGET_PATH }}
```
Copy file via a SSH key: Copy file via a SSH key:
```yaml ```yaml