appleboy/scp-action

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

karimuddin2021 opened this issue · 4 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/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

Also experiencing this!

same here even after update version!!

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"`

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