Compare commits

..

4 Commits

Author SHA1 Message Date
appleboy
3d59448764
docs: enhance SSH configuration documentation and testing
- Replace detailed SCP and SSH proxy settings with a table format for better readability
- Improve clarity and grammar in instructions for creating and using SSH keys

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-12-25 09:04:14 +08:00
appleboy
2a829c0ed2
docs: improve API performance and update documentation
- Fix grammar in README to clarify Linux Docker container support

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-12-24 22:15:22 +08:00
Bo-Yi Wu
4f2c27bbc2
docs: improve documentation and testing configurations (#193)
- Add example for using environment variables with `scp-action` in README.md

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-12-24 22:09:30 +08:00
appleboy
b03d7257ae
style: improve readability and functionality across multiple components
- Remove an empty line in the jobs section
- Reformat the list of SCP options for better readability
- Reformat the list of SSH proxy settings for better readability
- Reformat the instructions for SSH login without a password for better readability

Signed-off-by: appleboy <appleboy.tw@gmail.com>
2024-12-24 22:05:54 +08:00

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 support **Linux** [docker](https://www.docker.com/) container. **Important**: Only supports **Linux** [docker](https://www.docker.com/) containers.
## Usage ## Usage
@ -14,7 +14,6 @@ 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
@ -35,46 +34,50 @@ jobs:
See the [action.yml](./action.yml) file for more detail information. See the [action.yml](./action.yml) file for more detail information.
* host - scp remote host | Variable | Description | Default Value |
* port - scp remote port, default is `22` | ------------------- | ----------------------------------------------------------------------------------------------------------- | ------------- |
* username - scp username | host | SCP remote host | - |
* password - scp password | port | SCP remote port | `22` |
* passphrase - the passphrase is usually to encrypt the private key | username | SCP username | - |
* protocol - The IP protocol to use. Valid values are `tcp`. `tcp4` or `tcp6`. Default to `tcp`. | password | SCP password | - |
* fingerprint - fingerprint SHA256 of the host public key, default is to skip verification | passphrase | The passphrase is usually used to encrypt the private key | - |
* timeout - timeout for ssh to remote host, default is `30s` | protocol | The IP protocol to use. Valid values are `tcp`, `tcp4`, or `tcp6`. | `tcp` |
* command_timeout - timeout for scp command, default is `10m` | fingerprint | Fingerprint SHA256 of the host public key. Default is to skip verification | - |
* key - content of ssh private key. ex raw content of ~/.ssh/id_rsa | timeout | Timeout for SSH to remote host | `30s` |
* key_path - path of ssh private key | command_timeout | Timeout for SCP command | `10m` |
* target - target path on the server, must be a directory (**required**) | key | Content of SSH private key. e.g., raw content of ~/.ssh/id_rsa | - |
* source - scp file list (**required**) | key_path | Path of SSH private key | - |
* rm - remove target folder before upload data, default is `false` | target | Target path on the server, must be a directory (**required**) | - |
* strip_components - remove the specified number of leading path elements. | source | SCP file list (**required**) | - |
* overwrite - use `--overwrite` flag with tar, overwrite existing files when extracting | rm | Remove target folder before uploading data | `false` |
* tar_tmp_path - temporary path for tar file on the dest host | strip_components | Remove the specified number of leading path elements | - |
* tar_exec - path to tar executable on the dest host. default is `tar` | overwrite | Use `--overwrite` flag with tar, overwrite existing files when extracting | - |
* tar_dereference - use `--dereference` flag with tar, follow symlinks; archive and dump the files they point to | tar_tmp_path | Temporary path for tar file on the destination host | - |
* use_insecure_cipher - include more ciphers with use_insecure_cipher (see [#15](https://github.com/appleboy/scp-action/issues/15)) | tar_exec | Path to tar executable on the destination host | `tar` |
| 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:
* proxy_host - proxy host | Variable | Description | Default Value |
* proxy_port - proxy port, default is `22` | ------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------- |
* proxy_username - proxy username | proxy_host | Proxy host | - |
* proxy_password - proxy password | proxy_port | Proxy port | `22` |
* proxy_protocol - The IP protocol to use. Valid values are `tcp`. `tcp4` or `tcp6`. Default to `tcp`. | proxy_username | Proxy username | - |
* proxy_passphrase - the passphrase is usually to encrypt the private key | proxy_password | Proxy password | - |
* proxy_timeout - timeout for ssh to proxy host, default is `30s` | proxy_protocol | The IP protocol to use. Valid values are `tcp`, `tcp4`, or `tcp6`. | `tcp` |
* proxy_key - content of ssh proxy private key. | proxy_passphrase | The passphrase is usually used to encrypt the private key | - |
* proxy_key_path - path of ssh proxy private key | proxy_timeout | Timeout for SSH to proxy host | `30s` |
* proxy_fingerprint - fingerprint SHA256 of the host public key, default is to skip verification | proxy_key | Content 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_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)) | - |
## Setting up a SSH Key ## Setting up a SSH Key
Make sure to follow the below steps while creating SSH Keys and using them. Make sure to follow the steps below when creating and using SSH keys.
The best practice is create the SSH Keys on local machine not remote machine. The best practice is to create the SSH keys on the local machine, not the remote machine.
Login with username specified in Github Secrets. Generate a RSA Key-Pair: Log in with the username specified in GitHub Secrets and generate an RSA key pair:
```bash ```bash
# rsa # rsa
@ -108,9 +111,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
@ -149,6 +152,20 @@ 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
@ -208,7 +225,7 @@ Example configuration for exclude custom files:
Upload artifact files to remote server: Upload artifact files to remote server:
```yaml ```yaml
deploy: deploy:
name: deploy artifact name: deploy artifact
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -273,7 +290,7 @@ foobar
Only copy files that are newer than the corresponding destination files: Only copy files that are newer than the corresponding destination files:
```yaml ```yaml
changes: changes:
name: test changed-files name: test changed-files
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps: