appleboy / scp-action

GitHub Action that copy files and artifacts via SSH.
https://github.com/marketplace/actions/scp-command-to-transfer-files
MIT License
1.22k stars 136 forks source link

tar: empty archive #169

Open frederickbeaulieu opened 6 months ago

frederickbeaulieu commented 6 months ago

I get tar: empty archive when using the SCP action inside my Gitea Runner deployed in a docker container.

I tried to use folder structure used in this repository and the exact action definition, but no success.

image

image

scillidan commented 6 months ago

I had the same problem. My action runs well before. Recently, I re-created my repo. On my PC, I need to use ssh -o StrictHostKeyChecking=no VPSuser@MyIp to log in VPS. And when I used the same configuration with Github Actions, it failed.

My config:

- name: Checkout
  uses: actions/checkout@v4
- name: Get changed files
  id: changed-files
  uses: tj-actions/changed-files@v35
  with:
    since_last_remote_commit: true
    separator: ","
- name: copy file to server
  uses: appleboy/scp-action@v0.1.7
  with:
    host: ${{ secrets.VPS_HOST }}
    username: ${{ secrets.VPS_USERNAME }}
    key: ${{ secrets.VPS_KEY }}
    # password: ${{ secrets.VPS_PASSWORD }}
    port: ${{ secrets.VPS_PORT }}
    source: "./html/*"
    target: /var/www/sub-domains/byya/

And when I use password, it return:

Run appleboy/scp-action@v0.1.7
...
drone-scp version: v1.6.14
tar all files into /tmp/ucUfUXaNUK.tar.gz
remote server os type is unix
scp file to server.
20[24](https://github.com/scillidan/BYYA-site/actions/runs/8122976226/job/22203873158#step:14:25)/03/02 14:53:48 error copy file to dest: ***, error message: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
drone-scp error: error copy file to dest: ***, error message: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

When I use ssh-key, it return:

Run appleboy/scp-action@v0.1.7
...
drone-scp version: v1.6.14
tar all files into /tmp/ySUWcqCQnb.tar.gz
tar: empty archive
exit status 1
ZachSARAO commented 5 months ago

I've been using this action for about 4 years now - it's been helpful. I always, always, always struggle to get the source / target to work correctly as I'm never sure what directories should exist on the target, or what other rules are. The 'empty archive' message isn't helpful. Would it be possible to please improve the logging so that we know what the target directory is at runtime?

ddjerqq commented 5 months ago

this really needs improving, its really misleading and a horrible error message, how could we improve the error message? are there are any issues open addressing this?

LucasRomier commented 3 months ago

I am having the same problem, changing the tar_tmp_path is not registered either

ddjerqq commented 3 months ago

I fixed this issue, the problem was with paths, if anyone else is having issues, Please make sure your paths are correct! the trailing and leading slashes matter. The action does not give clear error messages.

here are some examples of how I am using this action after fixing the issue:

- name: Copy the source to the server 🔁
  uses: appleboy/scp-action@v0.1.7
  with:
    host: ${{ secrets.SSH_HOST }}
    username: ${{ secrets.SSH_USER }}
    key: ${{ secrets.SSH_KEY }}
    source: "."
    target: "~/src"
    overwrite: true
    strip_components: 1
- name: Copy dist content to server 🔁
  uses: appleboy/scp-action@v0.1.7
  with:
    host: ${{ secrets.SSH_HOST }}
    username: ${{ secrets.SSH_USER }}
    key: ${{ secrets.SSH_KEY }}
    source: "./dist/wwwroot/*"
    target: "~/dist/"
    rm: true
    overwrite: true
    strip_components: 2

Notice the slashes, and the home directory! make sure the directory you're SCP-ing to exists on the remote machine. Make sure you have correct permissions. If you still cant get it to work @ me. I will help you! Good luck

mabonfanti commented 1 month ago

@ddjerqq what if I want to transfer a xml file from a remote windows server into my workspace? I have been using this but I keep getting the empty file error message:

image

This is my code:

image

ddjerqq commented 1 month ago

it is an issue with path names of the files, fix it, use absolute path names, please refer to this guide about scp https://linuxize.com/post/how-to-use-scp-command-to-securely-transfer-files/

mabonfanti commented 1 month ago

@ddjerqq I think my issue is that I want to do a copy from a Windows server into the github workspace:

In that example the Windows Server Host is the source where the XML file is and I need to copy that one from there into my workspace to then do an update and sent it back to the server updated. Do you know if the scp works both ways? Does it support scp files from target host to drone itself?