scp-action icon indicating copy to clipboard operation
scp-action copied to clipboard

tar: empty archive

Open frederickbeaulieu opened this issue 1 year ago • 14 comments
trafficstars

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

frederickbeaulieu avatar Mar 12 '24 14:03 frederickbeaulieu

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/[email protected]
  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/[email protected]
...
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/[email protected]
...
drone-scp version: v1.6.14
tar all files into /tmp/ySUWcqCQnb.tar.gz
tar: empty archive
exit status 1

scillidan avatar Mar 21 '24 12:03 scillidan

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?

ZachSARAO avatar Apr 11 '24 10:04 ZachSARAO

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?

ddjerqq avatar Apr 20 '24 15:04 ddjerqq

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

LucasRomier avatar Jun 11 '24 15:06 LucasRomier

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/[email protected]
  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/[email protected]
  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

ddjerqq avatar Jun 12 '24 15:06 ddjerqq

@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

mabonfanti avatar Aug 27 '24 20:08 mabonfanti

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/

ddjerqq avatar Aug 27 '24 22:08 ddjerqq

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

  • name: Pull Appman from rsapns0001 server uses: appleboy/scp-action@master with: host: ${{ env.WINDOWS_SERVER_HOST }} username: ${{ env.WINDOWS_DEPLOY_USER }} key: ${{ secrets.SSH_PRIVATE_KEY }} port: 22 source: "/D:/ResApps/prodbase/x86/appman/appman.xml" target: /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?

mabonfanti avatar Aug 28 '24 19:08 mabonfanti

Please make sure your runner's /tmp is mounted to Docker host's /tmp

https://github.com/orgs/community/discussions/141270#discussion-7310106

Cow258 avatar Oct 12 '24 14:10 Cow258