GitHub Action that copy files and artifacts via SSH.
GitHub Action for copying files and artifacts via SSH.
Important: Only support Linux docker container.
Copy files and artifacts via SSH:
name: scp files on: [push] jobs:build: name: Build runs-on: ubuntu-latest steps: - uses: actions/[email protected] - name: copy file via ssh password uses: appleboy/[email protected] with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} source: "tests/a.txt,tests/b.txt" target: "test"
See the action.yml file for more detail information.
22
30s
10m
false
--overwriteflag with tar
SSH Proxy Setting:
22
30s
Copy file via a SSH password:
- name: copy file via ssh password uses: appleboy/[email protected] with: host: example.com username: foo password: bar port: 22 source: "tests/a.txt,tests/b.txt" target: "test"
Copy file via a SSH key:
- name: copy file via ssh key uses: appleboy/[email protected] 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:
- name: copy file via ssh key uses: appleboy/[email protected] with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} port: ${{ secrets.PORT }} key: ${{ secrets.KEY }} source: "tests/*.txt,!tests/a.txt" target: "test"
Example configuration for multiple servers:
uses: appleboy/s[email protected] 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:
- name: remove the specified number of leading path elements uses: appleboy/[email protected] 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:
foobar └── tests ├── a.txt └── b.txt
New target structure:
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.
- name: ssh key with passphrase uses: appleboy/[email protected] 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"