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

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

Open karimuddin2021 opened this issue 1 year ago • 5 comments

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/[email protected]. and it's working as expected.

- name: Copy Docker image to EC2
  uses: appleboy/[email protected]
  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

karimuddin2021 avatar Dec 28 '23 13:12 karimuddin2021

Also experiencing this!

grantholle avatar Jan 01 '24 07:01 grantholle

same here even after update version!!

allania7med11 avatar Jan 07 '24 14:01 allania7med11

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/[email protected]
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.PRIVATE_KEY }}
          source: "my-image.tar"
          target: "/home/ubuntu"`

fivlao avatar Jan 07 '24 18:01 fivlao

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

MohssineSERRAJI avatar Mar 21 '24 16:03 MohssineSERRAJI