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.14k stars 134 forks source link

Getting Errror, tar: can't open '***.tar': Permission denied #160

Open karimuddin2021 opened 6 months ago

karimuddin2021 commented 6 months ago

Getting errors on the master branch. with the same configuration was working fine before latest update 2 days ago. now I change versions appleboy/scp-action@master. to appleboy/scp-action@v0.1.4. and it's working as expected.

- name: Copy Docker image to EC2
  uses: appleboy/scp-action@v0.1.4
  with:
    host: ${{ secrets.INSTANCE_IP }}
    username: ubuntu
    key: ${{ secrets.SSH_PRIVATE_KEY }}
    source: "${{ secrets.DOCKER_REPO_NAME }}.tar"
    target: "/home/ubuntu/${{ secrets.DOCKER_REPO_NAME }}"

Error:

drone-scp version: v1.6.13 tar all files into /tmp/HDySbTIXlV.tar.gz tar: can't open '***.tar': Permission denied tar: error exit delayed from previous errors exit status 1

grantholle commented 6 months ago

Also experiencing this!

allania7med11 commented 5 months ago

same here even after update version!!

fivlao commented 5 months ago

I don't know how good this approach is, but I solved it like this: add: chmod 664 my-image.tar

Result workflow:

name: build-deploy

on:
  push:
    branches: [ "dev" ]
  pull_request:
    branches: [ "dev" ]

jobs:
  build-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build Docker image
        run: docker build . -f ./Dockerfile -t my-image:latest-dev

      - name: Save Docker image as tar file
        run: |
          docker save -o my-image.tar my-image:latest-dev
          chmod 664 my-image.tar

      - name: Transfer Docker image to remote server
        uses: appleboy/scp-action@v0.1.7
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.PRIVATE_KEY }}
          source: "my-image.tar"
          target: "/home/ubuntu"`
MohssineSERRAJI commented 3 months ago

Hello,

For my case, I tried adding: chmod 664 my-image.tar but it doesn't work for me. So I tried to check the ownership of the target folder I found that the owner is root I changed it to my username and it worked fine.

Replace username with the name of the user, groupname with the name of the group (if you also want to change the group ownership), and /path/to/folder with the path to the folder whose ownership you want to change.

If you only want to change the user ownership and keep the folder's group unchanged, you can omit the groupname:

sudo chown username /path/to/folder

Good luck