{"id":13474650,"url":"https://github.com/appleboy/scp-action","last_synced_at":"2025-05-14T01:08:38.189Z","repository":{"id":37706469,"uuid":"186096381","full_name":"appleboy/scp-action","owner":"appleboy","description":"GitHub Action that copy files and artifacts via SSH.","archived":false,"fork":false,"pushed_at":"2025-03-17T17:57:00.000Z","size":277,"stargazers_count":1353,"open_issues_count":83,"forks_count":140,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T09:31:02.313Z","etag":null,"topics":["github-action","github-actions","scp"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/scp-command-to-transfer-files","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appleboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.paypal.me/appleboy46"]}},"created_at":"2019-05-11T06:27:38.000Z","updated_at":"2025-04-08T12:06:13.000Z","dependencies_parsed_at":"2023-01-11T17:21:19.335Z","dependency_job_id":"8d4e9879-1078-4bd8-b4b9-f6e8a727d060","html_url":"https://github.com/appleboy/scp-action","commit_stats":{"total_commits":121,"total_committers":8,"mean_commits":15.125,"dds":"0.15702479338842978","last_synced_commit":"c6ff96b7f6d4941429ff4b6aa5b9b0e1c7ff38ea"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appleboy%2Fscp-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appleboy%2Fscp-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appleboy%2Fscp-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appleboy%2Fscp-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appleboy","download_url":"https://codeload.github.com/appleboy/scp-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248243496,"owners_count":21071054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-action","github-actions","scp"],"created_at":"2024-07-31T16:01:13.821Z","updated_at":"2025-04-10T15:42:48.402Z","avatar_url":"https://github.com/appleboy.png","language":"Shell","funding_links":["https://www.paypal.me/appleboy46"],"categories":["Community Resources","Shell"],"sub_categories":["Deployment"],"readme":"# 🚀 SCP for GitHub Actions\n\n[GitHub Action](https://github.com/features/actions) for copying files and artifacts via SSH.\n\n[![Actions Status](https://github.com/appleboy/scp-action/workflows/scp%20files/badge.svg)](https://github.com/appleboy/scp-action/actions)\n\n**Important**: Only supports **Linux** [docker](https://www.docker.com/) containers.\n\n## Usage\n\nCopy files and artifacts via SSH:\n\n```yaml\nname: scp files\non: [push]\njobs:\n  build:\n    name: Build\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: copy file via ssh password\n        uses: appleboy/scp-action@v0.1.7\n        with:\n          host: ${{ secrets.HOST }}\n          username: ${{ secrets.USERNAME }}\n          password: ${{ secrets.PASSWORD }}\n          port: ${{ secrets.PORT }}\n          source: \"tests/a.txt,tests/b.txt\"\n          target: your_server_target_folder_path\n```\n\n## Input variables\n\nSee the [action.yml](./action.yml) file for more detail information.\n\n| Variable            | Description                                                                                                 | Default Value |\n| ------------------- | ----------------------------------------------------------------------------------------------------------- | ------------- |\n| host                | SCP remote host                                                                                             | -             |\n| port                | SCP remote port                                                                                             | `22`          |\n| username            | SCP username                                                                                                | -             |\n| password            | SCP password                                                                                                | -             |\n| passphrase          | The passphrase is usually used to encrypt the private key                                                   | -             |\n| protocol            | The IP protocol to use. Valid values are `tcp`, `tcp4`, or `tcp6`.                                          | `tcp`         |\n| fingerprint         | Fingerprint SHA256 of the host public key. Default is to skip verification                                  | -             |\n| timeout             | Timeout for SSH to remote host                                                                              | `30s`         |\n| command_timeout     | Timeout for SCP command                                                                                     | `10m`         |\n| key                 | Content of SSH private key. e.g., raw content of ~/.ssh/id_rsa                                              | -             |\n| key_path            | Path of SSH private key                                                                                     | -             |\n| target              | Target path on the server, must be a directory (**required**)                                               | -             |\n| source              | SCP file list (**required**)                                                                                | -             |\n| rm                  | Remove target folder before uploading data                                                                  | `false`       |\n| strip_components    | Remove the specified number of leading path elements                                                        | -             |\n| overwrite           | Use `--overwrite` flag with tar, overwrite existing files when extracting                                   | -             |\n| tar_tmp_path        | Temporary path for tar file on the destination host                                                         | -             |\n| tar_exec            | Path to tar executable on the destination host                                                              | `tar`         |\n| tar_dereference     | Use `--dereference` flag with tar, follow symlinks; archive and dump the files they point to                | -             |\n| use_insecure_cipher | Include more ciphers with use_insecure_cipher (see [#15](https://github.com/appleboy/scp-action/issues/15)) | -             |\n\nSSH Proxy Setting:\n\n| Variable                  | Description                                                                                                 | Default Value |\n| ------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------- |\n| proxy_host                | Proxy host                                                                                                  | -             |\n| proxy_port                | Proxy port                                                                                                  | `22`          |\n| proxy_username            | Proxy username                                                                                              | -             |\n| proxy_password            | Proxy password                                                                                              | -             |\n| proxy_protocol            | The IP protocol to use. Valid values are `tcp`, `tcp4`, or `tcp6`.                                          | `tcp`         |\n| proxy_passphrase          | The passphrase is usually used to encrypt the private key                                                   | -             |\n| proxy_timeout             | Timeout for SSH to proxy host                                                                               | `30s`         |\n| proxy_key                 | Content of SSH proxy private key                                                                            | -             |\n| proxy_key_path            | Path of SSH proxy private key                                                                               | -             |\n| proxy_fingerprint         | Fingerprint SHA256 of the host public key. Default is to skip verification                                  | -             |\n| proxy_use_insecure_cipher | Include more ciphers with use_insecure_cipher (see [#15](https://github.com/appleboy/scp-action/issues/15)) | -             |\n\n## Setting up a SSH Key\n\nMake sure to follow the steps below when creating and using SSH keys.\nThe best practice is to create the SSH keys on the local machine, not the remote machine.\nLog in with the username specified in GitHub Secrets and generate an RSA key pair:\n\n```bash\n# rsa\nssh-keygen -t rsa -b 4096 -C \"your_email@example.com\"\n\n# ed25519\nssh-keygen -t ed25519 -a 200 -C \"your_email@example.com\"\n```\n\nAdd newly generated key into Authorized keys. Read more about authorized keys [here](https://www.ssh.com/ssh/authorized_keys/).\n\n```bash\n# rsa\ncat .ssh/id_rsa.pub | ssh b@B 'cat \u003e\u003e .ssh/authorized_keys'\n\n# d25519\ncat .ssh/id_ed25519.pub | ssh b@B 'cat \u003e\u003e .ssh/authorized_keys'\n```\n\nCopy Private Key content and paste in Github Secrets.\n\n```bash\n# rsa\nclip \u003c ~/.ssh/id_rsa\n\n# ed25519\nclip \u003c ~/.ssh/id_ed25519\n```\n\nSee the detail information about [SSH login without password](http://www.linuxproblem.org/art_9.html).\n\n**A note** from one of our readers: Depending on your version of SSH you might also have to do the following changes:\n\n- Put the public key in `.ssh/authorized_keys2`\n- Change the permissions of `.ssh` to 700\n- Change the permissions of `.ssh/authorized_keys2` to 640\n\n### If you are using OpenSSH\n\nIf you are currently using OpenSSH and are getting the following error:\n\n```bash\nssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey]\n```\n\nMake sure that your key algorithm of choice is supported.\nOn Ubuntu 20.04 or later you must explicitly allow the use of the ssh-rsa algorithm. Add the following line to your OpenSSH daemon file (which is either `/etc/ssh/sshd_config` or a drop-in file under `/etc/ssh/sshd_config.d/`):\n\n```bash\nCASignatureAlgorithms +ssh-rsa\n```\n\nAlternatively, `ed25519` keys are accepted by default in OpenSSH. You could use this instead of rsa if needed:\n\n```bash\nssh-keygen -t ed25519 -a 200 -C \"your_email@example.com\"\n```\n\n## Example\n\nCopy file via a SSH password:\n\n```yaml\n- name: copy file via ssh password\n  uses: appleboy/scp-action@v0.1.7\n  with:\n    host: example.com\n    username: foo\n    password: bar\n    port: 22\n    source: \"tests/a.txt,tests/b.txt\"\n    target: your_server_target_folder_path\n```\n\nUsing the environment variables\n\n```yaml\n- name: copy file via ssh password\n  uses: appleboy/scp-action@v0.1.7\n  with:\n    host: ${{ env.HOST }}\n    username: ${{ env.USERNAME }}\n    password: ${{ secrets.PASSWORD }}\n    port: ${{ env.PORT }}\n    source: \"tests/a.txt,tests/b.txt\"\n    target: ${{ env.TARGET_PATH }}\n```\n\nCopy file via a SSH key:\n\n```yaml\n- name: copy file via ssh key\n  uses: appleboy/scp-action@v0.1.7\n  with:\n    host: ${{ secrets.HOST }}\n    username: ${{ secrets.USERNAME }}\n    port: ${{ secrets.PORT }}\n    key: ${{ secrets.KEY }}\n    source: \"tests/a.txt,tests/b.txt\"\n    target: your_server_target_folder_path\n```\n\nExample configuration for ignore list:\n\n```yaml\n- name: copy file via ssh key\n  uses: appleboy/scp-action@v0.1.7\n  with:\n    host: ${{ secrets.HOST }}\n    username: ${{ secrets.USERNAME }}\n    port: ${{ secrets.PORT }}\n    key: ${{ secrets.KEY }}\n    source: \"tests/*.txt,!tests/a.txt\"\n    target: your_server_target_folder_path\n```\n\nExample configuration for multiple servers:\n\n```diff\n  uses: appleboy/scp-action@v0.1.7\n  with:\n-   host: \"example.com\"\n+   host: \"foo.com,bar.com\"\n    username: foo\n    password: bar\n    port: 22\n    source: \"tests/a.txt,tests/b.txt\"\n    target: your_server_target_folder_path\n```\n\nExample configuration for exclude custom files:\n\n```yaml\n  uses: appleboy/scp-action@v0.1.7\n  with:\n    host: \"example.com\"\n    username: foo\n    password: bar\n    port: 22\n-   source: \"tests/*.txt\"\n+   source: \"tests/*.txt,!tests/a.txt,!tests/b.txt\"\n    target: your_server_target_folder_path\n```\n\nUpload artifact files to remote server:\n\n```yaml\ndeploy:\n  name: deploy artifact\n  runs-on: ubuntu-latest\n  steps:\n    - name: checkout\n      uses: actions/checkout@v4\n\n    - run: echo hello \u003e world.txt\n\n    - uses: actions/upload-artifact@v4\n      with:\n        name: my-artifact\n        path: world.txt\n\n    - uses: actions/download-artifact@v4\n      with:\n        name: my-artifact\n        path: distfiles\n\n    - name: copy file to server\n      uses: appleboy/scp-action@v0.1.7\n      with:\n        host: ${{ secrets.HOST }}\n        username: ${{ secrets.USERNAME }}\n        key: ${{ secrets.KEY }}\n        port: ${{ secrets.PORT }}\n        source: distfiles/*\n        target: your_server_target_folder_path\n```\n\nRemove the specified number of leading path elements:\n\n```yaml\n- name: remove the specified number of leading path elements\n  uses: appleboy/scp-action@v0.1.7\n  with:\n    host: ${{ secrets.HOST }}\n    username: ${{ secrets.USERNAME }}\n    key: ${{ secrets.KEY }}\n    port: ${{ secrets.PORT }}\n    source: \"tests/a.txt,tests/b.txt\"\n    target: your_server_target_folder_path\n    strip_components: 1\n```\n\nOld target structure:\n\n```sh\nfoobar\n  └── tests\n    ├── a.txt\n    └── b.txt\n```\n\nNew target structure:\n\n```sh\nfoobar\n  ├── a.txt\n  └── b.txt\n```\n\nOnly copy files that are newer than the corresponding destination files:\n\n```yaml\nchanges:\n  name: test changed-files\n  runs-on: ubuntu-latest\n  steps:\n    - name: checkout\n      uses: actions/checkout@v4\n\n    - name: Get changed files\n      id: changed-files\n      uses: tj-actions/changed-files@v35\n      with:\n        since_last_remote_commit: true\n        separator: \",\"\n\n    - name: copy file to server\n      uses: appleboy/scp-action@v0.1.7\n      with:\n        host: ${{ secrets.HOST }}\n        username: ${{ secrets.USERNAME }}\n        key: ${{ secrets.KEY }}\n        port: ${{ secrets.PORT }}\n        source: ${{ steps.changed-files.outputs.all_changed_files }}\n        target: your_server_target_folder_path\n```\n\nProtecting 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.\n\n```diff\n  - name: ssh key with passphrase\n    uses: appleboy/scp-action@v0.1.7\n    with:\n      host: ${{ secrets.HOST }}\n      username: ${{ secrets.USERNAME }}\n      key: ${{ secrets.SSH2 }}\n+     passphrase: ${{ secrets.PASSPHRASE }}\n      port: ${{ secrets.PORT }}\n      source: \"tests/a.txt,tests/b.txt\"\n      target: your_server_target_folder_path\n```\n\nWhen copying files from a Linux runner to a Windows server, you should:\n\n1. Download git for Windows\n2. Change the default OpenSSH shell to git bach with the following powershell command.\n3. Set `tar_dereference` and `rm` variable to `true` in the YAML file\n4. Avoid putting the `port` value through a variable\n5. Convert the target path to a Unix path: `/c/path/to/target/`\n\nChange the default OpenSSH shell to git bach with the following powershell command.\n\n```powershell\nNew-ItemProperty -Path \"HKLM:\\SOFTWARE\\OpenSSH\" -Name DefaultShell -Value \"$env:Programfiles\\Git\\bin\\bash.exe\" -PropertyType String -Force\n```\n\nConvert the target path to a Unix path: `/c/path/to/target/`\n\n```diff\n  - name: Copy to Windows\n      uses: appleboy/scp-action@v0.1.7\n      with:\n        host: ${{ secrets.HOST }}\n        username: ${{ secrets.USERNAME }}\n        key: ${{ secrets.SSH_PRIVATE_KEY }}\n        port: 22\n        source: 'your_source_path'\n-       target: 'C:\\path\\to\\target'\n+       target: '/c/path/to/target/'\n+       tar_dereference: true\n+       rm: true\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappleboy%2Fscp-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappleboy%2Fscp-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappleboy%2Fscp-action/lists"}